| 1 |
================== |
| 2 |
Settings Reference |
| 3 |
================== |
| 4 |
|
| 5 |
Here is a list of all available settings of django-filters and their |
| 6 |
default values. All settings are prefixed with ``FILTERS_``, although this |
| 7 |
is a bit verbose it helps to make it easy to identify these settings. |
| 8 |
|
| 9 |
|
| 10 |
FILTERS_DEFAULT_LOOKUP_EXPR |
| 11 |
--------------------------- |
| 12 |
|
| 13 |
Default: ``'exact'`` |
| 14 |
|
| 15 |
Set the default lookup expression to be generated, when none is defined. |
| 16 |
|
| 17 |
|
| 18 |
FILTERS_EMPTY_CHOICE_LABEL |
| 19 |
-------------------------- |
| 20 |
|
| 21 |
Default: ``'---------'`` |
| 22 |
|
| 23 |
Set the default value for ``ChoiceFilter.empty_label``. You may disable the empty choice by setting this to ``None``. |
| 24 |
|
| 25 |
|
| 26 |
FILTERS_NULL_CHOICE_LABEL |
| 27 |
------------------------- |
| 28 |
|
| 29 |
Default: ``None`` |
| 30 |
|
| 31 |
Set the default value for ``ChoiceFilter.null_label``. You may enable the null choice by setting a non-``None`` value. |
| 32 |
|
| 33 |
|
| 34 |
FILTERS_NULL_CHOICE_VALUE |
| 35 |
------------------------- |
| 36 |
|
| 37 |
Default: ``'null'`` |
| 38 |
|
| 39 |
Set the default value for ``ChoiceFilter.null_value``. You may want to change this value if the default ``'null'`` string conflicts with an actual choice. |
| 40 |
|
| 41 |
|
| 42 |
FILTERS_DISABLE_HELP_TEXT |
| 43 |
------------------------- |
| 44 |
|
| 45 |
Default: ``False`` |
| 46 |
|
| 47 |
Some filters provide informational ``help_text``. For example, csv-based |
| 48 |
filters (``filters.BaseCSVFilter``) inform users that "Multiple values may |
| 49 |
be separated by commas". |
| 50 |
|
| 51 |
You may set this to ``True`` to disable the ``help_text`` for **all** |
| 52 |
filters, removing the text from the rendered form's output. |
| 53 |
|
| 54 |
|
| 55 |
.. _verbose-lookups-setting: |
| 56 |
|
| 57 |
FILTERS_VERBOSE_LOOKUPS |
| 58 |
----------------------- |
| 59 |
|
| 60 |
.. note:: |
| 61 |
|
| 62 |
This is considered an advanced setting and is subject to change. |
| 63 |
|
| 64 |
Default: |
| 65 |
|
| 66 |
.. code-block:: python |
| 67 |
|
| 68 |
# refer to 'django_filters.conf.DEFAULTS' |
| 69 |
'VERBOSE_LOOKUPS': { |
| 70 |
'exact': _(''), |
| 71 |
'iexact': _(''), |
| 72 |
'contains': _('contains'), |
| 73 |
'icontains': _('contains'), |
| 74 |
... |
| 75 |
} |
| 76 |
|
| 77 |
This setting controls the verbose output for generated filter labels. Instead |
| 78 |
of getting expression parts such as "lt" and "contained_by", the verbose label |
| 79 |
would contain "is less than" and "is contained by". Verbose output may be |
| 80 |
disabled by setting this to a falsy value. |
| 81 |
|
| 82 |
This setting also accepts callables. The callable should not require arguments |
| 83 |
and should return a dictionary. This is useful for extending or overriding the |
| 84 |
default terms without having to copy the entire set of terms to your settings. |
| 85 |
For example, you could add verbose output for "exact" lookups. |
| 86 |
|
| 87 |
.. code-block:: python |
| 88 |
|
| 89 |
# settings.py |
| 90 |
def FILTERS_VERBOSE_LOOKUPS(): |
| 91 |
from django_filters.conf import DEFAULTS |
| 92 |
|
| 93 |
verbose_lookups = DEFAULTS['VERBOSE_LOOKUPS'].copy() |
| 94 |
verbose_lookups.update({ |
| 95 |
'exact': 'is equal to', |
| 96 |
}) |
| 97 |
return verbose_lookups |