Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django programmatically create permissions

from myapp.models import BlogPost
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType

content_type = ContentType.objects.get_for_model(BlogPost)
permission = Permission.objects.create(
    codename='can_publish',
    name='Can Publish Posts',
    content_type=content_type,
)
Source by docs.djangoproject.com #
 
PREVIOUS NEXT
Tagged: #django #programmatically #create #permissions
ADD COMMENT
Topic
Name
7+9 =