diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-12-07 16:19:37 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-12-07 16:19:37 +0000 |
| commit | 5f36d9d562a7f78befbb045d529081995ba3097a (patch) | |
| tree | 9383262ca24b0846a7b717b10974b12c52018a44 | |
| parent | c50d333c23a3c53d05623ce15df79e624c57f37c (diff) | |
Added django.contrib.contenttypes.management.create_all_contenttypes() function for convenience
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4183 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/contenttypes/management.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/django/contrib/contenttypes/management.py b/django/contrib/contenttypes/management.py index de3a685477..f492f54303 100644 --- a/django/contrib/contenttypes/management.py +++ b/django/contrib/contenttypes/management.py @@ -3,9 +3,9 @@ Creates content types for all installed models. """ from django.dispatch import dispatcher -from django.db.models import get_models, signals +from django.db.models import get_apps, get_models, signals -def create_contenttypes(app, created_models, verbosity): +def create_contenttypes(app, created_models, verbosity=2): from django.contrib.contenttypes.models import ContentType app_models = get_models(app) if not app_models: @@ -22,4 +22,11 @@ def create_contenttypes(app, created_models, verbosity): if verbosity >= 2: print "Adding content type '%s | %s'" % (ct.app_label, ct.model) +def create_all_contenttypes(verbosity=2): + for app in get_apps(): + create_contenttypes(app, None, verbosity) + dispatcher.connect(create_contenttypes, signal=signals.post_syncdb) + +if __name__ == "__main__": + create_all_contenttypes() |
