Tuesday, July 30, 2013

Re: User Permissions

On Tue, 30 Jul 2013 16:39:27 -0300
Carlos Leite <caduado@gmail.com> wrote:

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

That is slightly incorrect - Django _does_ have foundation for object (row) level permission system. There is just no default implementation in standard auth
module. User methods get_group_permissions, get_all_permissions, has_perm and has_perms does accept optional second parameter "obj" which if set anything else but None will check permission for spesific object instead of model.

<https://docs.djangoproject.com/en/1.5/topics/auth/customizing/> contains more info about customizing authentication backend.

> 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.
>
>

--

Jani Tiainen

--
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