Last active
August 29, 2015 14:25
-
-
Save edgabaldi/39796eeb163d57824a08 to your computer and use it in GitHub Desktop.
post migrate signal that create new permissions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:utf-8 | |
from south.signals import post_migrate | |
def update_permission_after_migration(app, **kwargs): | |
""" | |
your_project.__init__.py is a nice place to stay | |
Update app permission just after every migration. | |
This is based on app djando_extensions update_permissions management command. | |
""" | |
from django.conf import settings | |
from django.db.models import get_app, get_models | |
from django.contrib.auth.management import create_permissions | |
create_permissions(get_app(app), get_models(), 2 if settings.DEBUG else 0) | |
post_migrate.connect(update_permission_after_migration) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment