Sorry for the mistake:

class myCustomizedMan(models.Manager):
   def get_query_set(self):
      userid=threadlocals.get_current_user().id
      return 
super(myCustomizedMan,self).get_query_set().filter(your_user__id__exact=userid)

It was userid... ;) I'm tired!

2007/2/22, Picio <[EMAIL PROTECTED]>:
> Yes It's but depending on the deisgn of your project, may be It's better
> to build a custom view inside tha admin (as the djangobook  chapter 18 
> speaks).
> Anyway I do It this way:
>
> 1 - store the user id taken from a middleware from the superguru lukeplant
> http://lukeplant.me.uk/blog.php?id=1107301634
>
> 2 - create a custom manager for the class you want the change-list page will 
> be
> filtered  that override the get_query_set(), this is less or more mine:
>
> class myCustomizedMan(models.Manager):
>     def get_query_set(self):
>        userid=threadlocals.get_current_user().id
>        return 
> super(myCustomizedMan,self).get_query_set().filter(your_user__id__exact=id)
>
>
> 3 - I don't know if this problem still occur in 0.95.1 but in 0.95 If
> you want to use
> a custom manager you have to say it inside the admin class:
>
> class Admin:
>    ...
>    bla bla bla filter, list_display whatever you want
>    ...
>    manager = myCustomizedMan()
>
> This was my little hack to have rows filtered by user. People can't
> display other
> users rows, inside the admin change-list page.
>
> Please note that at the state of the art, if you choose to customize
> the admin, maybe you will find more and more hacks to do. Every time
> you achieve to customize the admin, It whet your appetite to other new
> things you need, and this never end. Django 1.0 will solve this admin
> customization issue with the new Admin class.
> So my little suggestion is:
> 1) try your custom views instead
> 2) try to customize the admin via chapter 18 of the djangobook
> 3) try my little tric (based on the superduperguruLukeplant great hack)
> 4) wait for the new Admin Class (maybe 0.96 will come soon)
>
> Bye
> Picio
> 5) read this fantasti news letter every day
>
> 2007/2/22, Django <[EMAIL PROTECTED]>:
> >
> > Hi,
> >
> > Is it possible to customise the django admin so that it only displays
> > certain objects depending on which user has logged in? For example I
> > have a user linked to one or more subject models. Is it possible only
> > to display the subjects which are linked to the user who is logged in
> > in the admin interface?
> >
> > I'm new to django so apologies if this is an obvious question.
> >
> >
> > > >
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to