[Answered ]-Django RegexValidator does not display message

2👍

You’re passing into template context form_class instead of form if your post request is POST and form is not valid. To solve the issue, change your last line of view to this three lines:

    else:
        form = form_class()

    return render(request, 'contact.html', {'form': form,})

It will create empty form if there is no post data and pass form instead of form_class to your template.

Leave a comment