Skip to content

Tag: widget

How to dynamically change Django Form field type (e.g. `forms.CharField` to `forms.ChoiceField`) without changing the data member variable?

TL;DR How can I change the search term CharField (of any of the rows in the image below) to another field type (e.g. ChoiceField, DateField, etc) based on the type of the selected database field (in the first select list on that row – see screenshot below)? Long version I have a cool hierarchical advanced search interface, e.g.: Each row