The permission / authentication documentation for Django 1.4 provides the following piece of software for creating custom permissions:
Edit: (I would like to use this for permissions that are not necessarily associated with a particular model class, but more general permissions that span multiple types.)
from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType content_type = ContentType.objects.get(app_label='myapp', model='BlogPost') permission = Permission.objects.create(codename='can_publish', name='Can Publish Posts', content_type=content_type)
A source
My question is where this code should be placed. Obviously, they should be created only once, but I do not want to do this in the shell. It seems that this should be stored in a file somewhere. (For documentation sake.)
Craig otis
source share