Commit c81fae6b authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Used app_label instead of appname.

The last component of the dotted path to the application module is
consistently referenced as the application "label". For instance it's
AppConfig.label. appname could be confused with AppConfig.name, which is
the full dotted path.
parent a7add2f2
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -16,10 +16,12 @@ class Command(BaseCommand):
        make_option('--indent', default=None, dest='indent', type='int',
            help='Specifies the indent level to use when pretty-printing output'),
        make_option('--database', action='store', dest='database',
            default=DEFAULT_DB_ALIAS, help='Nominates a specific database to dump '
                'fixtures from. Defaults to the "default" database.'),
            default=DEFAULT_DB_ALIAS,
            help='Nominates a specific database to dump fixtures from. '
                 'Defaults to the "default" database.'),
        make_option('-e', '--exclude', dest='exclude', action='append', default=[],
            help='An appname or appname.ModelName to exclude (use multiple --exclude to exclude multiple apps/models).'),
            help='An app_label or app_label.ModelName to exclude '
                 '(use multiple --exclude to exclude multiple apps/models).'),
        make_option('-n', '--natural', action='store_true', dest='use_natural_keys', default=False,
            help='Use natural keys if they are available.'),
        make_option('--natural-foreign', action='store_true', dest='use_natural_foreign_keys', default=False,
@@ -27,15 +29,17 @@ class Command(BaseCommand):
        make_option('--natural-primary', action='store_true', dest='use_natural_primary_keys', default=False,
            help='Use natural primary keys if they are available.'),
        make_option('-a', '--all', action='store_true', dest='use_base_manager', default=False,
            help="Use Django's base manager to dump all models stored in the database, including those that would otherwise be filtered or modified by a custom manager."),
        make_option('--pks', dest='primary_keys', help="Only dump objects with "
            "given primary keys. Accepts a comma separated list of keys. "
            help="Use Django's base manager to dump all models stored in the database, "
                 "including those that would otherwise be filtered or modified by a custom manager."),
        make_option('--pks', dest='primary_keys',
            help="Only dump objects with given primary keys. "
                 "Accepts a comma separated list of keys. "
                 "This option will only work when you specify one model."),
    )
    help = ("Output the contents of the database as a fixture of the given "
            "format (using each model's default manager unless --all is "
            "specified).")
    args = '[appname appname.ModelName ...]'
    args = '[app_label app_label.ModelName ...]'

    def handle(self, *app_labels, **options):
        format = options.get('format')
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class Command(NoArgsCommand):
        yield "#   * Remove `managed = False` lines for those models you wish to give write DB access"
        yield "# Feel free to rename the models, but don't rename db_table values or field names."
        yield "#"
        yield "# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'"
        yield "# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [app_label]'"
        yield "# into your database."
        yield "from __future__ import unicode_literals"
        yield ''
+1 −1
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ class Command(BaseCommand):
        run_syncdb = False
        target_app_labels_only = True
        if len(args) > 2:
            raise CommandError("Too many command-line arguments (expecting 'appname' or 'appname migrationname')")
            raise CommandError("Too many command-line arguments (expecting 'app_label' or 'app_label migrationname')")
        elif len(args) == 2:
            app_label, migration_name = args
            if app_label not in executor.loader.migrated_apps:
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ class Command(BaseCommand):

        # Resolve command-line arguments into a migration
        if len(args) != 2:
            raise CommandError("Wrong number of arguments (expecting 'sqlmigrate appname migrationname')")
            raise CommandError("Wrong number of arguments (expecting 'sqlmigrate app_label migrationname')")
        else:
            app_label, migration_name = args
            if app_label not in executor.loader.migrated_apps:
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ class MigrationExecutor(object):
        plan = []
        applied = set(self.loader.applied_migrations)
        for target in targets:
            # If the target is (appname, None), that means unmigrate everything
            # If the target is (app_label, None), that means unmigrate everything
            if target[1] is None:
                for root in self.loader.graph.root_nodes():
                    if root[0] == target[0]:
Loading