Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to make a form field not part of the submitted form

I have an extra field in a django form that triggers javascript to change the fields in other forms:

class MyForm(forms.ModelForm):
    my_extra_form_field = forms.ChoiceField()

    class Meta:
        model = MyModel
        fields = ["field1", "field2"]

    field_order = ["field1", "my_extra_form_field", "field2"]

How can I ensure that my_extra_form_field is not included in the submiteed form?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

adding to NixionSparrow’s answer:

You may need to add the attribute required as mentioned in the docs here

my_extra_form_field = forms.ChoiceField(required=False)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading