*Hi,* *What i understood is that you need two different forms on single page. and later on you want to map feedback form as site specific.*
*So you can do with two different ways:* *1) define two different form action path.* *<form id="login_form" action="{% url app.views.contactus %}" method="post"> ...form fields...</form><form id="registration_form" action="{% url app.views.feedback %}" method="post"> ...form fields...</form>* *2) you have will have to provide two different buttons in template say * <input type="submit" value="Submit" name="contactus"> <input type="submit" value="Feedback" name="feedback"> And write view for it, which will identify response method This view is only for saving contact us if request.method == 'POST' && 'contactus' in request.post : contactform = contactForm(request.POST) if contactform.is_valid(): contactform.save() elif request.method == 'POST' && 'feedback' in request.post : feedbackform = feedbackForm(request.POST) if feedbackform.is_valid(): feedbackform.save() else: contactform = contactForm() feedbackform = feedbackform() Thanks, Aj On Monday, 19 January 2015 15:43:34 UTC+5:30, Tobias Dacoir wrote: > > I need to include two different contact forms in my app. One a general > contact form and another Report / Feedback form that pre-fills some data > depending on which site it was called from. > So I hit google, found django-contact-form, installed it and after > creating some basic templates (and rest of the configuration) I was able to > make use of /contact/ to present a basic form which takes in Name, Email > and Message. Works fine. > > Now I need that Report Form. The idea is to have a 'Report' Button on the > Website which maps to /report/$Parameter (or maybe it will just put the > parameter into request, not sure yet how to do this). > However I have troubles getting my Custom Form to work. I tried to create > a new view that uses my custom form which just inherits from ContactForm: > > forms.py: > class ReportForm(ContactForm): > additional = forms.CharField(max_length=100, label='additional field > test') > subject_template_name = "contact_form/report_form_subject.txt" > template_name = 'contact_form/report_form.txt' > > > > views.py: > def report(request): > reportForm = ReportForm > return render(request, 'play/report.html', {'form': reportForm}) > > > > > template report.html: > {% extends 'base.html' %} > > {% block body_block %} > <h2>Report Form</h2> > <p>To send us a message fill out the below form.</p> > <form method="post">{% csrf_token %} > <p>Name: <input type="text" name="name"></p> > <p>Your e-mail: <input type="text" name="email"></p> > <p>additional field test: <input type="text" name="additional"</p> > <p>Message: <textarea name="body" rows="10" cols="50"></textarea></p> > <input type="submit" value="Submit"> > </form> > {% endblock %} > > However it's not working at all. I can see the form displayed thanks to > the HTML Template, but nothing is happening when I press Submit. There is > no example on the website on how to subclass it :( > http://django-contact-form.readthedocs.org/en/latest/quickstart.html > Or should I just copy and paste the whole code from here and adapt it to > include additional fields: > https://bitbucket.org/ubernostrum/django-contact-form/src/4b7d2fa20c1d01568fb7c4c800155378e176923b/contact_form/forms.py?at=default > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e87aaafb-f842-418c-9e26-6c7dd71e94a7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.