#25679: ModelForm.Meta.fields and exclude are not honoured for custom fields ----------------------------+----------------------- Reporter: tino | Owner: nobody Type: Bug | Status: new Component: Forms | Version: master Severity: Normal | Keywords: modelform Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------+----------------------- [https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#selecting- the-fields-to-use 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.: {{{ 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) -- Ticket URL: <https://code.djangoproject.com/ticket/25679> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/047.e03af2f691f845c24a1a92126fbbfee1%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.