diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2008-06-11 14:01:35 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2008-06-11 14:01:35 +0000 |
| commit | 9c50495464db24eaad30984519ab9e31b5ffb044 (patch) | |
| tree | f7e349c92289b29811382a32395ddeb21e941344 | |
| parent | 5e202f5acf36f33e1b530514ff205536fe1fd62f (diff) | |
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
| -rw-r--r-- | django/core/management/commands/dumpdata.py | 13 | ||||
| -rw-r--r-- | docs/django-admin.txt | 16 |
2 files changed, 25 insertions, 4 deletions
diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index 2642ae925e..29f9f5fe63 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -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] diff --git a/docs/django-admin.txt b/docs/django-admin.txt index e14737c944..e8e3b54945 100644 --- a/docs/django-admin.txt +++ b/docs/django-admin.txt @@ -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 ~~~~~~~~ |
