Tuesday, July 30, 2013

Re: User Permissions

Django do not have a "per-row" permission system in the box.
You will have to create that by yourself.

You may start adding something like "owner" to your content type.
this field will be somthing like

owner = models.ForeignKey(User)

then, based on "request.user" in your views (for instance),
you may filter objects using .objects.filter(owner=requet.user)

hope that helps.



On Tue, Jul 30, 2013 at 12:39 PM, <ghinfey@screenscene.ie> wrote:
> Hi All,
>
> I have a very simple django site.
> The site allows the administrator to create a model which contains 5 text
> items and then stores that to the sqlite database.
> I have also created a user login page from a tutorial on youtube.
> I want to be able to control which model the logged in user has access to.
> For instance I want user "John" to be able to see logged model entries 1-5
> and not 6-7.
> Is this simple? How should I go about setting permissions?
>
> Any help is appreciated. If you would like specific code please ask.
>
> Thanks
>
>
>
>
> --
> 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 http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
--------------------
Cadu Leite
twitter: @cadu_leite
http://people.python.org.br/

--
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 http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment