Backup may unintentionally omit data that is filtered out by a custom manager
Problem
As described in the dumpdata documentation:
Note that dumpdata uses the default manager on the model for selecting the records to dump. If you’re using a custom manager as the default manager and it filters some of the available records, not all of the objects will be dumped.
and
--all, -a
Uses Django’s base manager, dumping records which might otherwise be filtered or modified by a custom manager.
Thus, as the current implementation does not use --all
, backup may unintentionally omit data that is filtered out by a custom manager. This did actually happen in the Wholesaler project.
Solution
Add all=True
as follows to call_command()
in create_backup()
in implementation.py
and, while at it, save backup bytes by making the indent shorter:
def create_backup(filename, silent):
verbosity = 0 if silent else 1
- call_command('dumpdata', indent=2, verbosity=verbosity, output=filename)
+ call_command('dumpdata', all=True, indent=1, verbosity=verbosity, output=filename)
Edited by Mart Sõmermaa