# put this in a templatetag library:
from django.template import Library

register = Library()



def admin_list_filter_select(cl, spec):
    choices = list(spec.choices(cl))
    # query_string of a non-all option will contain the name of our param (skipping '?'):
    # ?param1=x&fieldname_param=y
    key = (k.split('=')[0] for k in choices[-1]['query_string'][1:].split('&')
           if k.startswith(spec.field.name)).next()
    for c in choices:
        # find the option's value by looking after our key and skipping '='
        if key in c['query_string']:
            c['val'] = c['query_string'].split(key)[1].split('&')[-1][1:]
        else:
            c['val'] = ''    
    return {'field_name': key,
            'title': spec.title(), 
            'choices' : choices}
            
admin_list_filter_select = register.inclusion_tag('admin/filter_select.html')(admin_list_filter_select)



# template: 
{% load i18n %}
<label>{% blocktrans with title|escape as filter_title %} By {{ filter_title }} {% endblocktrans %}</label>
<select name="{{ field_name }}">
{% for choice in choices %}
    <option {% if choice.selected %} selected="selected"{% endif %} value="{{ choice.val }}">{{ choice.display|escape }}</option>
{% endfor %}
</select>



# modify your admin/change_list.hml to include the templatetag lib and this code: (for example
# in the search block:
...
{% block search %}{% search_form cl %}
{% if cl.has_filters %}
<form action="." method="get">
{% for spec in cl.filter_specs %}
   {% admin_list_filter_select cl spec %}
{% endfor %}
<input type="submit"/>
</form>
{% endif %}
{% endblock %}


