1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

magic-removal: Fixed #1471 -- Changed manage.py installperms to work with apps without model classes. Thanks, Christopher Lenz

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2514 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-03-13 00:20:57 +00:00
parent e695567d10
commit 0d9ab72fea

View File

@ -430,7 +430,7 @@ def syncdb():
sys.stderr.write("Permissions will not be installed because it "\ sys.stderr.write("Permissions will not be installed because it "\
"appears that you are not using Django's auth framework. "\ "appears that you are not using Django's auth framework. "\
"If you want to install them in the future, re-run syncdb."\ "If you want to install them in the future, re-run syncdb."\
"\n(The full error was: %s)" % e) "\n(The full error was: %s)\n" % e)
transaction.rollback_unless_managed() transaction.rollback_unless_managed()
else: else:
transaction.commit_unless_managed() transaction.commit_unless_managed()
@ -563,9 +563,11 @@ def installperms(app):
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from django.db.models import get_models from django.db.models import get_models
num_added = 0
app_models = get_models(app) app_models = get_models(app)
if not app_models:
return
app_label = app_models[0]._meta.app_label app_label = app_models[0]._meta.app_label
num_added = 0
for klass in app_models: for klass in app_models:
opts = klass._meta opts = klass._meta
ctype = ContentType.objects.get_for_model(klass) ctype = ContentType.objects.get_for_model(klass)