Hello everyone,

I have two models: PublicAccount and Order.

I need to provide a link to filter Orders by PublicAccount. So, I
added a field to the list display of my PublicAccount:

def orders(self):
    return '<a href="%s?public_account_id=%s">View</a>' % \
        (reverse('admin:orders_order_changelist'), self.pk)
orders.allow_tags = True


Here's my override for the Order queryset:

def queryset(self, request):
    qs = super(OrderAdmin, self).queryset(request)
    public_account_id = request.GET.get('public_account_id', None)
    if public_account_id:
        qs.filter(public_account__id=str(public_account_id))
    return qs


What's happening is that the admin view is reloading. When I pass in
the public_account_id= through the querystring, the queryset will get
filtered as expected, but then the page immediately reloads and I end
up with a parameter: ?e=1 in the querystring.

If I print the qs variable, I get the result I expect, but then I get
another unfiltered list. I have no other overrides in my OrderAdmin
class. Does anyone know what's going on?

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

Reply via email to