Monday, September 13, 2010

Overriding queryset for admin.ModelAdmin

Hi everyone,

I have a very strange problem I'm trying to get a handle on. I need to
filter a model admin with a value from the querystring, so I am doing
an override of queryset in my ModelAdmin like so:

def queryset(self, request):
id = request.GET.get('id', None)
if id:
return BidLocationGroup.objects.filter(bid__pk=id)
else:
return BidLocationGroup.objects.all()

When I watch the development server in Terminal and print out the
variable "id", here's what I see:

[13/Sep/2010 19:20:10] "GET /admin/bids/bidlocationgroup/ HTTP/1.1"
200 3292
[13/Sep/2010 19:20:10] "GET /static/js/jquery-1.4.2.min.js HTTP/1.1"
200 72174
[13/Sep/2010 19:20:10] "GET /static/js/admin_shared.js HTTP/1.1" 200
1239
[13/Sep/2010 19:20:10] "GET /static/js/parseuri.js HTTP/1.1" 200 1055
[13/Sep/2010 19:20:10] "GET /static/css/custom_admin.css HTTP/1.1" 200
1657
bid_id: 19
[13/Sep/2010 19:20:16] "GET /admin/bids/bidlocationgroup/?bid_id=19
HTTP/1.1" 302 0
bid_id: None
[13/Sep/2010 19:20:16] "GET /admin/bids/bidlocationgroup/?e=1 HTTP/
1.1" 200 3292

What the hell?! Why is passing in a parameter causing a redirect? How
can I prevent this from happening?

TIA,
Brandon

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate