Description

The followings are some usage examples for AdminTextInputFilter. The newly created class could then be inserted in ListFilter or be specified in the matching ModelAdmin list_filter.

Exact match

class TextInputFilterExact(AdminTextInputFilter):
    parameter_name = 'data1'
    title = 'Data 1'
    lookup_condition = 'exact'

Filters the model records including those whose data1 field matches the exact specified value.

Partial match with contains

class TextInputFilterContains(AdminTextInputFilter):
    parameter_name = 'data1'
    title = 'Data 1'
    lookup_condition = 'contains'

Filters the model records including those whose data1 field contains the specified value.

class TextInputFilterIContains(AdminTextInputFilter):
    parameter_name = 'data1'
    title = 'Data 1'
    lookup_condition = 'icontains'

Filters the model records including those whose data1 field contains the specified value, ignoring any differences between upper and lower case.

Initial or final match

class TextInputFilterStarting(AdminTextInputFilter):
    parameter_name = 'data1'
    title = 'Data 1'
    lookup_condition = 'startswith'

Filters the model records including those whose data1 field begins with the indicated value.

class TextInputFilterIEnding(AdminTextInputFilter):
    parameter_name = 'data1'
    title = 'Data 1'
    lookup_condition = 'iendswith'

Filters the model records including those whose data1 field ends with the indicated value, ignoring any differences between upper and lower case.

Match with regular expression

class TextInputFilterRegex(AdminTextInputFilter):
    parameter_name = 'data1'
    title = 'Data 1'
    lookup_condition = 'regex'

Filters the model records including those whose data1 field matches the regular expression with the indicated value.

For example, specifying on the filter the value ^[0-9]{4}$ only the records with 4 digits in the data1 field will be found.

Match with regular expression using an advanced filter

class TextInputFilterData1(AdminTextInputFilter):
    parameter_name = 'data1'
    title = 'Data 1'
    lookup_condition_advanced = 'data1__regex'

Filters the model records including those whose data1 field matches the regular expression with the indicated value, using the advanced filter.

For example, specifying on the filter the value ^[0-9]{4}$ only the records with 4 digits in the data1 field will be found.