[Answer]-Django Crispy form will not save/submit

1👍

Your view isn’t ok. At the moment you only create a form and render it. Nothing is done when the form is posted, it is just rendered again. So in case of a POST, check if the form is valid and save it. So that will make it something like:

def customercrispy(request):
    if request.method == 'POST': 
        form = ExampleForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('customercripsy') # name of view stated in urls
    else:
        form = ExampleForm()

    return render_to_response("customer-crispy.html",
                          {"example_form": form},
                          context_instance=RequestContext(request))

This also avoids you to set ‘/customeroverview/’ as form action. If you really want to post to this url, add the customeroverview view to your question. Btw, I would advice you to use django’s reverse function to create your urls. (https://docs.djangoproject.com/en/dev/ref/urlresolvers/#reverse).

More documentation about modelforms in your view: https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-model-formset-in-a-view

Leave a comment