Search code examples
djangoformsvalidationpreviewconfirmation

Django Form with preview and confirmation


Disclaimer: I'm a beginner at Django.

I'm trying to create an app where I want the customer to preview and confirm a form before submitting it. I tried using the built-in Django FormPreview, but discovered that it didn't support File fields, so I threw it away.

Could anyone point me in the right direction?


Solution

  • A concept idea would be:

    In your template:

    <input name='preview' type='submit' />
    <input name='submit' type='submit' />
    

    in the view to fetch your post:

    form = YourFormName(request.POST)
    if 'preview' in request.POST:
        # here you return the response you wish
        # the user to see when trying preview
        # for example form.is_valid()
        # could be nice to deal with
    if 'submit' in request.POST:
        # normal form handling