Django

Code

Changeset 7615

Show
Ignore:
Timestamp:
06/11/08 09:01:35 (3 months ago)
Author:
russellm
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/management/commands/dumpdata.py

    r7294 r7615  
    1010        make_option('--indent', default=None, dest='indent', type='int', 
    1111            help='Specifies the indent level to use when pretty-printing output'), 
     12        make_option('-e', '--exclude', dest='exclude',action='append', default=[],  
     13            help='App to exclude (use multiple --exclude to exclude multiple apps).'), 
    1214    ) 
    1315    help = 'Output the contents of the database as a fixture of the given format.' 
     
    1719        from django.db.models import get_app, get_apps, get_models 
    1820 
    19         format = options.get('format', 'json') 
    20         indent = options.get('indent', None) 
    21         show_traceback = options.get('traceback', False) 
     21        format = options['format'] 
     22        indent = options['indent'] 
     23        exclude = options['exclude'] 
     24        show_traceback = options['traceback'] 
     25 
     26        excluded_apps = [get_app(app_label) for app_label in exclude] 
    2227 
    2328        if len(app_labels) == 0: 
    24             app_list = get_apps() 
     29            app_list = [app for app in get_apps() if app not in excluded_apps] 
    2530        else: 
    2631            app_list = [get_app(app_label) for app_label in app_labels] 
  • django/trunk/docs/django-admin.txt

    r7614 r7615  
    164164 
    165165.. _custom manager: ../model-api/#custom-managers 
     166 
     167--exclude 
     168~~~~~~~~~ 
     169 
     170**New in Django development version** 
     171 
     172Exclude a specific application from the applications whose contents is 
     173output. For example, to specifically exclude the `auth` application from 
     174the output, you would call:: 
     175 
     176        django-admin.py dumpdata --exclude=auth 
     177 
     178If you want to exclude multiple applications, use multiple ``--exclude`` 
     179directives:: 
     180 
     181        django-admin.py dumpdata --exclude=auth --exclude=contenttype 
    166182 
    167183--format