Ticket #12767: block_contenttypes.diff

File block_contenttypes.diff, 860 bytes (added by Adam Vandenberg, 8 years ago)

Hack: blocks command if ContentType isn't allowed to sync into the target db.

  • django/contrib/contenttypes/management.py

    diff --git a/django/contrib/contenttypes/management.py b/django/contrib/contenttypes/management.py
    index 61ee285..8bbf065 100644
    a b  
    11from django.contrib.contenttypes.models import ContentType
     2from django.db import router
    23from django.db.models import get_apps, get_models, signals
    34from django.utils.encoding import smart_unicode
    def update_contenttypes(app, created_models, verbosity=2, **kwargs): 
    89    entries that no longer have a matching model class.
    910    """
    1011    db = kwargs['db']
     12    if not router.allow_syncdb(db, ContentType):
     13        return
    1115    ContentType.objects.clear_cache()
    1216    content_types = list(ContentType.objects.using(db).filter(app_label=app.__name__.split('.')[-2]))
    1317    app_models = get_models(app)
Back to Top