django-objectdump 0.3 documentation
Installation is easy using pip.
$ pip install django-objectdump
Add to INSTALLED_APPS
Optionally add configuration information (OBJECTDUMP_SETTINGS)
Object Dump’s settings currently consist of one item: MODEL_SETTINGS. MODEL_SETTINGS is a dict with the keys as 'app.model' strings and the values a dict with one or more key-value pairs.
If 'app.model' key is not in MODEL_SETTINGS, object dump uses the defaults.
If one of the fields is not in the 'app.model's dict, object dump uses the default for that field.
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
'reverse_relations': True, # or False, or ['whitelist', 'of', 'reverse_relations']
}
}
}
Default: False
If True, always ignore this model. Acts as if you used --exclude with this model.
Default: True
If False, do not include related objects through foreign keys. Otherwise, a white-list of foreign keys to include related objects.
Default: True
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.
Default: True
If False, do not include additional objects using the reverse relations from this model. Reverse relations are usually accessed by “othermodel_set”.
Default: json
Specifies the output serialization format for fixtures. Options depend on SERIALIZATION_MODULES settings. xml and json and yaml are built-in.
Default: None
Specifies the indent level to use. The default will not do any pretty-printing or indenting of content.
Default: DEFAULT_DB_ALIAS
Nominates a specific database to dump fixtures from. Defaults to the “default” database.
Default: []
An appname or appname.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).
Default: False
Use natural keys if they are available.
Default: None
Max depth related objects to get. The initial object specified is considered level 0. The default will get all objects.
Default: None
Max number of related objects to get. Default gets all related objects.
Default: all
An appname or appname.ModelName to whitelist related objects included in the export (use multiple --include to include multiple apps/models).
Default: 'int'
The natural type of the id(s) specified. Options are: int, unicode, long
Default: False
Output debug information. Shows what related objects each object generates. Use with --verbosity 2 to also see which fields are the link.