Ticket #16385: e9cb952ff9052caa223dfa90529d869c00108674.diff

File e9cb952ff9052caa223dfa90529d869c00108674.diff, 1.0 KB (added by Jonas H., 13 years ago)

Permission creation __in

  • django/contrib/auth/management/__init__.py

    diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
    index 46dbea8..5f625aa 100644
    a b def create_permissions(app, created_models, verbosity, **kwargs):  
    3535    # Find all the Permissions that have a context_type for a model we're
    3636    # looking for.  We don't need to check for codenames since we already have
    3737    # a list of the ones we're going to create.
    38     all_perms = set(auth_app.Permission.objects.filter(
    39         content_type__in=ctypes,
    40     ).values_list(
    41         "content_type", "codename"
    42     ))
     38    all_perms = set()
     39    ctypes_pks = set(ct.pk for ct in ctypes)
     40    for ctype, codename in auth_app.Permission.objects.all().values_list(
     41            'content_type', 'codename')[:1000000]:
     42        if ctype in ctypes_pks:
     43            all_perms.add((ctype, codename))
    4344
    4445    for ctype, (codename, name) in searched_perms:
    4546        # If the permissions exists, move on.
Back to Top