Permalink
Browse files

Fixed #7254 -- Added an '--exclude' option to dumpdata, allowing spec…

…ific 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
  • Loading branch information...
1 parent 5e202f5 commit 9c50495464db24eaad30984519ab9e31b5ffb044 @freakboy3742 freakboy3742 committed Jun 11, 2008
Showing with 25 additions and 4 deletions.
  1. +9 −4 django/core/management/commands/dumpdata.py
  2. +16 −0 docs/django-admin.txt
@@ -9,19 +9,24 @@ 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 ...]'
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]
View
@@ -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
~~~~~~~~

0 comments on commit 9c50495

Please sign in to comment.