New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing an initial value #160
Comments
I'm wondering this as well, I dove through the different Filter, FilterSet, and Form objects and didn't find a decent way to do this. I don't believe initial will work because it is using a bound form, although I didn't find a good work around passing the data itself. I found a workaround through the QueryDict and passing that to the FilterSet but there has to be a cleaner way to do this. |
Would you mind posting a snippet of your workaround? I'm kind of stuck at this point and my users are tired of having their searches default to Afghanistan :) |
Hi @chromakey — I think this is a usage question so it's better aimed at the Mailing List. However, the form's data is just that passed to the FilterSet, so if I understand you correctly you should be able to do something like this:
If that's not it please follow up and explain more on the Mailing List. Thanks. |
I searched the mailing list but could not find a solution. Here is a workaround that I figured out (use at your own discretion):
|
in case of ChoiceField you can use: |
I've tried to pass an initial value to the form by separately trying the following methods (yadda being a placeholder value):
Neither seems to work. How can I set an initial value for the form when using django-filters?
The text was updated successfully, but these errors were encountered: