How to add an initial/default value using Django Filters?
<p>How can I add an initial/default value when using <a href="https://github.com/carltongibson/django-filter" rel="nofollow">Django Filters</a>?</p>

<p>For example, something like this <code>initial=False</code></p>

<pre><code>class UserFilter(django_filters.FilterSet):
    archive = django_filters.BooleanFilter(initial=False)

    class Meta:
         model = User
         fields = ['archive']
</code></pre>

<p>I've tired to override the <code>__init__</code> but this does not appear to work.</p>

<p>You can try overriding the <code>__init__</code> method of <code>UserFilter</code>:</p>

<pre><code>def __init__(self, *args, **kwargs):
    super(UserFilter, self).__init__(*args, **kwargs)
    self.form.initial['archive'] = False
</code></pre>

python django