[Answered ]-Django Wagtail ajax contact form

2๐Ÿ‘

โœ…

You should use {% url %} template tag.

urls.py :

from django.conf.urls import url
from yourapp.views import submitContact

urlpatterns = [
    url(r'^contact/$', submitContact, name='contact'),
]

Template :

<form class="form-group" role="form" method="post" action="{% url 'contact' %}">
 ......
</form>

Another improvement is to use Django Form.

Note : prefer lower_case_with_underscores naming style for functions. Use CamelCase for classes. See PEP8 for more information.

0๐Ÿ‘

Instead of trying to build it yourself, why not take a look at the already existing Form Builder of Wagtail?

It enables you to create a FormPage on which you can display a custom form and even E-mail the results.

Check out the documentation here.

๐Ÿ‘คJohan

Leave a comment