-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
"form" definition on "class Meta" of a FilterSet is not honored #1650
Comments
Hi @DanielSwain. The You may want to override that, e.g. if your form has exact fields specified, or to control the dynamic generation. |
Thank you @carltongibson. I did notice A search in the docs on |
You can. You can see in the code there that
Yes, good. Adding that to the FilterSet reference would be great. |
I need to modify what is displayed to the user for each item in a
<select>
by including in parentheses the count of a set of items thatForeignKey
to the main model. To do this, I defined a custom form and fields (including a queryset definition on the field displayed in the<select>
- see the very end of this question for additional information). I was gettingKeyError
on the first of the field names, so I then stripped down the form definition by simply declaring a filter form of typeforms.ModelForm
withexclude
:As I add each subsequent field from the fields in the model definition to
exclude
, I then get aKeyError
on the next, non-excluded field. It seems like theform
declaration isn't being honored. I looked at your source code in BaseFilterSet.get_fields().It appears that the
form
argument is possibly not being taken into account inget_fields()
. Is that right, or am I missing something?Incidentally, in order to modify what is displayed for each item in the
<select>
, I defined a customModelChoiceField
and used thelabel_from_instance
method as mentioned here.There will only ever be a small number of items in the
<select>
, and I includedselect_related
forrelated_model
on the queryset definition.The text was updated successfully, but these errors were encountered: