User related objects

16 views
Skip to first unread message

Jonathan Querubina

unread,
Jul 2, 2014, 11:22:04 AM7/2/14
to django...@googlegroups.com
Hi guys,

I need to  customize my admin to show only the data related to the user who inserted.

Example: When a user log in, the admin shows only the posts inserted by this user.

AFAIK, django only set permissions my model, not by objects.

Is there a way (or a pip package) to implement this?

Thanks!


 
Att//

Lachlan Musicman

unread,
Jul 2, 2014, 11:32:27 AM7/2/14
to django...@googlegroups.com
There are a couple of ways to do it, filtered queries are the obvious solution

https://docs.djangoproject.com/en/1.6/topics/db/queries/#retrieving-specific-objects-with-filters

But it would require that your model have either a group or owner
permission set.

(eg
class MyModel(models.Model):
permission_level = ForeignKey(PermissionGroup)
or
owner = ForeignKey(User)
)

This has some good examples too

http://www.django-rest-framework.org/api-guide/permissions


cheers
L.
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/E151B4A3-E3F3-4E26-9342-85E5212C2241%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
-----------------------------------------------------------------------------------------------------------
Adventure Time http://theholenearthecenteroftheworld.com/

Jonathan Querubina

unread,
Jul 2, 2014, 11:41:26 AM7/2/14
to django...@googlegroups.com
Is there a way to set the ForeignKey(User) or ForeignKey(PermissionGroup) automatically by the logged user?
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiM%2B5Eb8LxUv8N7cW7st8jesJ8Ec-m0wMj8WJAi3JC1YwA%40mail.gmail.com.

Jonathan Querubina

unread,
Jul 2, 2014, 11:42:38 AM7/2/14
to django...@googlegroups.com
My problem is doing this on django-admin.

Thanks!

On Jul 2, 2014, at 8:31 AM, Lachlan Musicman <dat...@gmail.com> wrote:

> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiM%2B5Eb8LxUv8N7cW7st8jesJ8Ec-m0wMj8WJAi3JC1YwA%40mail.gmail.com.

Lachlan Musicman

unread,
Jul 2, 2014, 11:57:04 AM7/2/14
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages