As you may know, currently neither South nor Django create permissions on models that are added after the initial creation.

So, you can always add them to you dev setup, test setup, live deployments etc etc, or add them as a migration.

Or, better IMO, is the method used here

 

# register a signal do update permissions every migration.
# This is based on app django_extensions update_permissions command
from south.signals import post_migrate
 
def update_permissions_after_migration(app,**kwargs):
    """
    Update app permission just after every migration.
    This is based on app django_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_permissions_after_migration)

Just add that into the __init__.py for the project and permissions will be automatically created after running a migration.

Pingbacks are closed.

Comments are closed.