__init__.py 674 Bytes
Newer Older
1 2 3
# register a signal do update permissions every migration.
# This is based on app django_extensions update_permissions command

4
from django.db.models.signals import post_migrate
5 6


7
def update_permissions_after_migration(sender, **kwargs):
8 9 10 11 12 13 14
    """
    Update app permission just after every migration.
    This is based on app django_extensions update_permissions
    management command.
    """

    from django.conf import settings
15
    from django.db.models import get_models
16 17
    from django.contrib.auth.management import create_permissions

18
    create_permissions(sender, get_models(), 2 if settings.DEBUG else 0)
19 20

post_migrate.connect(update_permissions_after_migration)