# admin.py

class InputFilter(admin.SimpleListFilter):
    template = 'patient/input_filter.html'

    def lookups(self, request, model_admin):
        # Dummy, required to show the filter.
        return ((),)

class PatientProfilePastDataFilter(InputFilter):
    parameter_name = 'patient'
    title = _('Past Record')

    def lookups(self, request, model_admin):
        return ( (),)

    def queryset(self, request, queryset):       
        return queryset.filter(admitted_on__lte = request.GET.get("from") , 
admitted_on__gte  
         = request.GET.get("to")  )

# patient/input_filter.html
{% load i18n %} 

<h3>{% blocktrans with filter_title=title %} By {{ filter_title }} {% 
endblocktrans %}</h3>
<ul>
    <li>
        {% with choices.0 as all_choice %}
        <form method="GET" action="">

            <!-- {% for k, v in all_choice.query_parts %}
            <input type="hidden" name="{{ k }}" value="{{ v }}" />
            {% endfor %} -->

            <input  type="date"
                    value="{{ spec.value|default_if_none:'' }}"
                    name="from"/>

            <input  type="date"
            value="{{ spec.value|default_if_none:'' }}"
            name="to"/>

            <button type="submit"  >filter</button>
            {% if not all_choice.selected %}
                <strong><a href="{{ all_choice.query_string }}">x {% trans 
'Remove' %}</a></strong>
            {% endif %}

        </form>
        {% endwith %}
    </li>
</ul>

 # 
.................................................................................


I want to add a custom text filter in django admin site... with 2 input 
fields. Is there a way to do this.. if so then please suggest me,  how can 
I add a custom text field in filter section.

Also, Thanks for the  respond on previous query... 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2dc28aa3-90d0-422f-8d9c-4b5f5b6fb7f6n%40googlegroups.com.

Reply via email to