[Django]-How to submit data to database using Django ModelForm?

5👍

You need add POST condition in your view, validate the form and then save it:
https://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-view

👤matino

0👍

If you are working with Django 1.5 try THIS

Maybe your view could be that:

class RecadoFormView(FormView):
    model_class = RecadoForm
    template_name = 'recados/index.html'

    def valid_form(self, form):
        form.instance.save() # Or form.save()
        return super(RecadoFormView, self).valid_form(form)

Leave a comment