We're using this 'hidden' feature as well, for similar reasons.
I built a search form that allows the user to select multiple parameters 
to filter by. I just named the form fields using the appropriate lookup 
form of the field names (for example, a form TextField named 
user__first_name, etc.). However, fields without values still get added 
to the GET request (e.g. /?user__first_name='John-Scott'&hometown='') so 
the problem with this is that the Django ORM then tries to filter 
results where the User object's first_name is 'John-Scott' AND the 
hometown is the empty string. I wrote a simple view hack that removes 
all the parameters with empty values and then redirects to the 
appropriate admin url so filter() is only passed parameters with values. 
If this was done in core, this would make this 'power' feature a little 
more easy to use. I think it could be as trivial as a change to 
get_query_string() in django.contrib.admin.views.main.Changelist that 
deletes keys with empty values. I could take a stab at writing up a 
patch if anyone else is interested.

Cheers,
John-Scott

jdetaeye wrote:
> Mingers,
>
> I have pretty much the same use case as you: I wanted the filtering in
> the admin to be more "like a spreadsheet".
>
> See the screenshot on my website to see how I solved the issue:
>   http://www.frepple.com/screenshots/miniadmin.png
> It allows the user to enter the filter value, select a filter
> operator, and also to export the data in CSV-format to a spreadsheet.
>
> The implementation is not based on customizing the admin, but
> implementing a generic view with very similar capabilities as the
> django changelist view. In all, around 800 lines of code.
>
> My 2 cents,
>
> Johan
>
> On Dec 26, 1:10 pm, Mingers <[EMAIL PROTECTED]> wrote:
>   
>> Hi everyone,
>>
>> I've been working on a problem where I'd like the admin to be able to
>> filter for rows based on certain conditions for the list display, i.e.
>> basically anything that can be used as keyword arguments in
>> <modelname>.objects.filter(**kwargs) should be allowed as a filter for
>> the list display.
>>
>> Current solutions aren't good enough:
>> 1) This isn't the same thing as search, which is used mainly for text.
>> 2) List_filter is no good when my range of values is very large (i.e.
>> if I have 100,000 values I'd be scrolling a long time before I found
>> the value I wanted), or if I want to get a range of values, say
>> between 10 and 20.
>>
>> This would also be nice for things like searching for a blog post
>> within a date range.
>>
>> Turns out, this is already partially implemented (by accident?).  From
>> the admin, you can already filter rows for the list display by passing
>> GET arguments, ie. /admin/<app>/<model>/?
>> <columnname>__gt=10&<columnname>__lt=20
>>
>> Well, I'm a django newbie, so you all can correct me if I'm wrong.  If
>> I'm not, it'd be nice if 1) it were documented and 2) if there was an
>> admin option for models so that you could have this functionality show
>> up in the admin (some kind of form would need to be designed pretty
>> much).  Thanks.
>>
>> Best,
>> Mingers
>>     
> >
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to