Selecting fields to use states that only form fields that are listed in Meta.fields or are not listed in Meta.exclude are used and "Any fields not included in a form by the above logic will not be set by the form’s save() method.".
But when I add a custom field, it is displayed and saved even when not included in fields or when excluded. Eg.:
Still displays "conditional_field".
The reason I wanted to use this, is conditionally toggle the field in __init__.
(Even if that is not the correct way to approach this, it still is unexpected behaviour)
But when I add a custom field, it is displayed and saved even when not included in fields or when excluded. Eg.:
class TestForm(forms.ModelForm): conditional_field = forms.TextField() class Meta: model = MyModel exclude = ('conditional_field',)
Still displays "conditional_field".
The reason I wanted to use this, is conditionally toggle the field in __init__.
(Even if that is not the correct way to approach this, it still is unexpected behaviour)
No comments:
Post a Comment