Skip to content

Instantly share code, notes, and snippets.

@edgabaldi
Last active August 29, 2015 14:25
Show Gist options
  • Save edgabaldi/39796eeb163d57824a08 to your computer and use it in GitHub Desktop.
Save edgabaldi/39796eeb163d57824a08 to your computer and use it in GitHub Desktop.
post migrate signal that create new permissions
#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