Loading docs/topics/auth.txt +2 −1 Original line number Diff line number Diff line Loading @@ -1654,10 +1654,11 @@ While custom permissions can be defined within a model's ``Meta`` class, you can also create permissions directly. For example, you can create the ``can_publish`` permission for a ``BlogPost`` model in ``myapp``:: from myapp.models import BlogPost 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') content_type = ContentType.objects.get_for_model(BlogPost) permission = Permission.objects.create(codename='can_publish', name='Can Publish Posts', content_type=content_type) Loading Loading
docs/topics/auth.txt +2 −1 Original line number Diff line number Diff line Loading @@ -1654,10 +1654,11 @@ While custom permissions can be defined within a model's ``Meta`` class, you can also create permissions directly. For example, you can create the ``can_publish`` permission for a ``BlogPost`` model in ``myapp``:: from myapp.models import BlogPost 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') content_type = ContentType.objects.get_for_model(BlogPost) permission = Permission.objects.create(codename='can_publish', name='Can Publish Posts', content_type=content_type) Loading