Hi, I am new to Django so sorry if it is a dumb question:
def contact_us(request):
if request.method == 'POST':
form = ContactForm(request.POST or None)
if form.is_valid():
sender_name = form.cleaned_data['name']
sender_email = form.cleaned_data['email']
message = "{0} has sent you a new message:\n\n{1}".format(sender_name, form.cleaned_data['message'])
send_mail('New Enquiry', message, sender_email, ['xxx@gmail.com'])
return HttpResponse('Thanks for contacting us!')
else:
form = ContactForm()
return render(request, 'member/home.html/', {'form': form})
this is views py
path('#contact-section/', views.contact_us, name='member-contact-us'),
this is URL #contact-section is the id in the home page
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" />
</form>
this is my form part in my home html
when I create a separate /contact-us html it works, I just cant embed it into my home page,I think maybe the issue is with the URL path?