mardi 30 juin 2015

Add a simple field to django form without updating the model

Django newbie here

I want to add a checkbox to django form, but this checkbox doesn't have to be stored in the database.

A trivial solution is to add it directly to the html template. But I want to keep the django format :

{{ form.as_p }}

So I thought that I need to add the checkbox in the form class.

I did the following :

    class MyForm(forms.ModelForm):
          ...
          check_box = forms.BooleanField(widget=forms.CheckboxInput)

But on the template I can't find the checkbox. Any idea ? Thanks




Aucun commentaire:

Enregistrer un commentaire