FYI – development site, work in progress.
I am using Django on a page with a form. However, I am also using a javascript tab function on this same page which highlights the tab with the correct on-page link / hash.
The default page = http://learntango.webfactional.com/video/35863752#section=comment
The contact-us page = http://learntango.webfactional.com/video/35863752#section=contact
When the form is not valid, the page is returned (good). However, it is the base page which is returned: http://learntango.webfactional.com/video/35863752
After that, the javascript then defaults this to the comment page.
How do I return the same page, with the “contact” on-page link active, so they can see their form errors and realize that the form did not submit?
Thanks!
David
def video(request, url_vimeo_id):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail(
'This is an e-mail from the website',
cd['message'],
cd.get('email', 'noreply@example.com'),
['dwyliu@gmail.com'],
)
return HttpResponseRedirect('http://www.learntodancetango.com')
return render_to_response('video.html',{'video': video,'next':next, 'form': form}, context_instance=RequestContext(request))
else:
form = ContactForm()
return render_to_response('video.html',{'video': video,'next':next, 'form': form}, context_instance=RequestContext(request))
Set form’s
actionashttp://learntango.webfactional.com/video/35863752#section=contact