Warning: This python script is designed for Django 0.96.
It exports data from models quite like the `dumpdata` command, and throws the
data to the standard output.
It fixes glitches with unicode/ascii characters. It looked like the 0.96
handles very badly unicode characters, unless you specify an argument that is
not available via the command line. The simple usage is:
$ python export_models.py -a <application1> [application2, application3...]
As a plus, it allows you to export only one or several models inside your
application, and not all of them:
$ python export_models.py application1.MyModelStuff application1.MyOtherModel
Of course, you can specify the output format (serializer) with the -f
(--format) option.
$ python export_models.py --format=xml application1.MyModel
- tool
- dump
- serialization
- export
- db
- database
This snippet provides support for dynamically importing templates. This helps you to avoid naming collisions and other problems.
The format is as follows:
1. `module.submodule.app:template.html`
2. `module.submodule.app:subfolder/template.html`
3. `module.submodule.app:/subfolder/template.html`
Assuming the module is located in '/var/', these would map (respectively) to:
1. `/var/module/submodule/app/templates/template.html`
2. `/var/module/submodule/app/templates/subfolder/template.html`
3. `/var/module/submodule/app/templates/subfolder/template.html`
The colon splits the the python module from the template directory, meaning you can import from anything that has a "templates" directory. This helps me to avoid naming collisions by specifying the application I'm referring to, without having to put long paths in my extends and include tags inside other templates. It's also dynamic in that if I move a library outside the old path, it has no effect on the templates.
To get this rolling, in your `settings.py` file, add the following::
>TEMPLATE_LOADERS = (
> 'addons.template_loader.load_template_source', # <--- add this
> 'django.template.loaders.app_directories.load_template_source',
> 'django.template.loaders.filesystem.load_template_source',
># 'django.template.loaders.eggs.load_template_source',
>)
- template
- dynamic
- import
- loader