Fixed #7254 -- Added an '--exclude' option to dumpdata, allowing specific applications to be removed from the dump output. Thanks to Carl Karsten for the idea and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7615 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5e202f5acf
commit
9c50495464
|
@ -9,6 +9,8 @@ class Command(BaseCommand):
|
|||
help='Specifies the output serialization format for fixtures.'),
|
||||
make_option('--indent', default=None, dest='indent', type='int',
|
||||
help='Specifies the indent level to use when pretty-printing output'),
|
||||
make_option('-e', '--exclude', dest='exclude',action='append', default=[],
|
||||
help='App to exclude (use multiple --exclude to exclude multiple apps).'),
|
||||
)
|
||||
help = 'Output the contents of the database as a fixture of the given format.'
|
||||
args = '[appname ...]'
|
||||
|
@ -16,12 +18,15 @@ class Command(BaseCommand):
|
|||
def handle(self, *app_labels, **options):
|
||||
from django.db.models import get_app, get_apps, get_models
|
||||
|
||||
format = options.get('format', 'json')
|
||||
indent = options.get('indent', None)
|
||||
show_traceback = options.get('traceback', False)
|
||||
format = options['format']
|
||||
indent = options['indent']
|
||||
exclude = options['exclude']
|
||||
show_traceback = options['traceback']
|
||||
|
||||
excluded_apps = [get_app(app_label) for app_label in exclude]
|
||||
|
||||
if len(app_labels) == 0:
|
||||
app_list = get_apps()
|
||||
app_list = [app for app in get_apps() if app not in excluded_apps]
|
||||
else:
|
||||
app_list = [get_app(app_label) for app_label in app_labels]
|
||||
|
||||
|
|
|
@ -164,6 +164,22 @@ dumped.
|
|||
|
||||
.. _custom manager: ../model-api/#custom-managers
|
||||
|
||||
--exclude
|
||||
~~~~~~~~~
|
||||
|
||||
**New in Django development version**
|
||||
|
||||
Exclude a specific application from the applications whose contents is
|
||||
output. For example, to specifically exclude the `auth` application from
|
||||
the output, you would call::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth
|
||||
|
||||
If you want to exclude multiple applications, use multiple ``--exclude``
|
||||
directives::
|
||||
|
||||
django-admin.py dumpdata --exclude=auth --exclude=contenttype
|
||||
|
||||
--format
|
||||
~~~~~~~~
|
||||
|
||||
|
|
Loading…
Reference in New Issue