Right now the "reportForm" variable is pointing to the RequestForm class,
not to an object, so you need to do it like this

reportForm = ReportForm()    # Take note of the parenthesis

In your template, your form tag need an action attribute (well, it's not
mandatory but it is highly advised). In this case if you want the same view
to process your form you just need to use ".".

<form method="post" action="." ... >

With those changes you should be able to render the form as usual:

{{ form.as_p }}

Also I'm not sure what do you mean when you say thet nothing is happening
when you pres the Submit button. As you have it right now it just calls the
same view ("report") that you wrote. Since the view does not have different
rules for GET and POST requests it just renders the same page again.

On Mon, Jan 19, 2015 at 7:13 AM, Tobias Dacoir <falc...@gmail.com> 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/e72e813c-d78b-433f-8444-e76a4129c862%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e72e813c-d78b-433f-8444-e76a4129c862%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALn3ei2Cu%3DJRZCeZAZ_%3DN6Hy%2B47FAErTAjZHzMNWcEo9nZMqug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to