Wednesday, June 1, 2016

Why are models must for permissions?

Why are all permissions linked to a model? I'm just learning the basics of permissions and wanted to set up a quick example where I wanted to have a single user who belongs to a group that has permission to access restricted content, let's say. So far I have created a group  and added the user to that group but now I am stuck -- which model should I associate the permission with? Should it be the User model here? Why not some other model? Why a model at all?

This example in the docs also has me confused: https://docs.djangoproject.com/en/1.9/topics/auth/default/#groups
It looks like we are creating a generic permission here (generic in the sense that Django doesn't know what to do with it right out of the box). Why, then, must it be tied to the BlogPost model?

I guess my broader concern is that a permission like 'access_restricted_content' is not linked to any one model. Maybe there's a way to create permissions without a model and I've missed it?

I think I'm going nuts . . .

~~Ankush

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/be02e8a3-ca72-47b6-b66d-152894c52e30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment