Hi,

> I have an Admin site which I want to filter based on request.user.
>
> My ModelAdmin class is something like this,
>
> class FilterOnUser(admin.ModelAdmin):
>     def queryset(self, request):
>         return self.model._default_manager.filter(user = request.user)
>
>     def get_form(self, request, obj=None, **kwargs):
>         form_class = super(FilterOnUser, self).get_form(self, request,
> **kwargs)
>         class MyModelForm(form_class):
>             def get_queryset(self):
>                 import pdb
>                 pdb.set_trace()
>                 return super(MyModelForm,
> self).get_queryset().filter(board = request.board)
>      return MyModelForm
>
> So when I navigate to the change view on my admin site the
> pdb.set_trace is not hit. What am I doing wrong?

I don't know what MyModelForm.get_queryset is intending to do here but
a ModelForm doesn't have such a method by default so you are not
really overriding anything in case that's what you are trying to do.
So "import pdb" is never getting executed by the Admin change list
because the Admin is not supposed to call get_queryset on the
ModelForm.

-RD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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