Embeded contact-form in homepage
Closed this issue · 1 comments
kentenzer commented
Hi,
I have setup the django-contact-form in my project and works perfectly, nice job!
Now I want it to be directly embedded it on the homepage:
In the index template I have:
{% include 'contact_form/contact_form.html' %}
Which displays the contact-form correctly.
Who should I handle the POST request in my existing view?
Thanks,
kentenzer commented
I found a working solution, not sure if it is the correct one:
In my view.py:
from contact_form.forms import ContactForm
def index(request):
if request.method == 'POST':
form = ContactForm(request.POST or None, request=request)
if form.is_valid(): # checking if the form input is valid
form.save()
return render(request, 'myapp/index.html')