Hi!
I have a problems thats been bugging me for a while. I want to use dates in django admin to view entries between certain dates. To do this I have customized my changelist.html for this model and put a form in there. When posted I override the queryset method like this
def queryset(self, request):
qs = super(ModelAdmin, self).queryset(request)
if request.POST.has_key('date1'):
return qs.filter(startdate__gte=request.POST['date1']).filter(startdate__lte=request.POST['date2'])
return qs
This works great but its only one little problem. The parameters are forgotten if I for example choose to sort the result in any way.
If I instead of this type in the url straight into the browser so it looks like this
http//localhost/admin/some/model/?startdate_gte=2010-01-01&startdate_lte=2010-12-30
I can sort however I want to afterwards because they´ll stick just like this http//localhost/admin/some/model/?o=5&ot=asc&startdate_lte=2010-12-30&startdate_gte=2010-01-01
Do I need to use a filterspec to solve this?
Thanks heaps!