-
I have read docs, source code, and more source code - is there no way to configure a default selected value for the LookupChoiceFilter dropdown? Django 3.2 I currently have a LookupChoiceFilter as follows
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
Alternatively, is it possible for me to supply the whole dropdown form element myself? |
Beta Was this translation helpful? Give feedback.
-
You should be able to pass the |
Beta Was this translation helpful? Give feedback.
-
Just for fun i also tried this, no worky
|
Beta Was this translation helpful? Give feedback.
-
See the test case here: django-filter/tests/test_forms.py Lines 161 to 170 in 4a618e0 ... but you have to pass the initial data in the format expect for the multi-value field... |
Beta Was this translation helpful? Give feedback.
-
Solution: I could get no version of After having read hundreds of documentation pages and source code lines for both Django and django-filters i found that this will work - there will be no empty option element, and the first tuple in If this is how it is supposed to be done i strongly suggest it is added to the documentation, optionally the correct way.
|
Beta Was this translation helpful? Give feedback.
Solution:
empty_label=None,
I could get no version of
inital
to work.After having read hundreds of documentation pages and source code lines for both Django and django-filters i found that this will work - there will be no empty option element, and the first tuple in
lookup_choices
will be the top of the list. It will not have theselected
HTML attribute, but still works.If this is how it is supposed to be done i strongly suggest it is added to the documentation, optionally the correct way.