Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Paulo Almeida
Hi Alireza, Yes, that did the trick! Thank you, Paulo On Thursday, June 14, 2012 2:26:46 PM UTC+1, Alireza Savand wrote: > > > > On Thursday, June 14, 2012 3:04:54 PM UTC+4, Paulo Almeida wrote: >> >> Hi, >> >> I would like to access the request.user in a ModelAdmin function, so I >> can filter

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Alireza Savand
And if it's just for logged-in user, you can do like https://gist.github.com/2930287 at the ModelAdmin -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/mxxG

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Alireza Savand
On Thursday, June 14, 2012 3:04:54 PM UTC+4, Paulo Almeida wrote: > > Hi, > > I would like to access the request.user in a ModelAdmin function, so I can > filter the results of a query based on the logged in user. I have these > models: > > class Speaker(models.Model): > name = models.CharF

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Paulo Almeida
Hi again, >From what I read in the 1.4 docs, the SimpleListFilter example is for list_filter and not list_display. To clarify what I wrote before, if a user endorses Speaker A and opposes Speaker B, I want the Speaker list in the admin site to show: |Name | Is endorsed | |A | True

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Paulo Almeida
Hi Melvyn, I've only been reading the Django 1.2 docs, because it's what's immediately available in my Linux distribution, but that would be an excellent reason to upgrade, if I can get it to work. Thanks, Paulo On Thursday, June 14, 2012 12:33:34 PM UTC+1, Melvyn Sopacua wrote: > > On 14-6-2

Re: Accessing request.user in a ModelAdmin function

2012-06-14 Thread Melvyn Sopacua
On 14-6-2012 13:04, Paulo Almeida wrote: > So then I could just add "is_endorsed" to the list_display variable to have > the endorsement status for that user in the Speaker list, in the Admin > site. Of course, this doesn't work because request isn't available in the > is_endorsed function. I g