Installation is easy using
pip.$ pip install django-objectdump
Add to
INSTALLED_APPSOptionally add configuration information (
OBJECTDUMP_SETTINGS)
OBJECTDUMP_SETTINGS = {
'MODEL_SETTINGS': {
'app.model': {
'ignore': False,
'fk_fields': True, # or False, or ['whitelist', 'of', 'fks']
'm2m_fields': True, # or False, or ['whitelist', 'of', 'm2m fields']
'addl_relations': [] # callable or 'othermodel_set.all' strings
}
}
}ignore- If
True, always ignore this model. Acts as if you used--excludewith this model. fk_fields- If
False, do not include related objects through foreign keys. Otherwise, a white-list of foreign keys to include related objects. m2m_keys- If
False, do not include related objects through many-to-many fields. Otherwise, a white-list of many-to-many field names to include related objects. addl_relations- A list of callables, which get passed an object, or strings in Django template syntax (
'author_set.all.0'becomes'object.author_set.all.0'and evaluates toobject.author_set.all()[0])
--formatDefault:
jsonSpecifies the output serialization format for fixtures. Options depend on
SERIALIZATION_MODULESsettings.xmlandjsonandyamlare built-in.--indentDefault:
NoneSpecifies the indent level to use. The default will not do any pretty-printing or indenting of content.
--databaseDefault:
DEFAULT_DB_ALIASNominates a specific database to dump fixtures from. Defaults to the "default" database.
-e,--excludeDefault:
[]An appname or appname.ModelName to exclude (use multiple
--excludeto exclude multiple apps/models).-n,--naturalDefault:
FalseUse natural keys if they are available.
--depthDefault:
NoneMax depth related objects to get. The initial object specified is considered level 0. The default will get all objects.
--limitDefault:
NoneMax number of related objects to get. Default gets all related objects.
-i,--includeDefault: all
An appname or appname.ModelName to whitelist related objects included in the export (use multiple
--includeto include multiple apps/models).--idtypeDefault:
'int'The natural type of the id(s) specified. Options are:
int,unicode,long--debugDefault:
FalseOutput debug information. Shows what related objects each object generates. Use with
--verbosity 2to also see which fields are the link.