I managed to do it! Thanks to your help.

Ok all you need to do is this:

views.py:
class ReportFormView(FormView):
    form_class = ReportForm
    template_name = 'contact_form/contact_form.html'

    def form_valid(self, form):
        form.save()
        return super(ReportFormView, self).form_valid(form)

    def get_form_kwargs(self):
        # ContactForm instances require instantiation with an
        # HttpRequest.
        kwargs = super(ReportFormView, self).get_form_kwargs()
        kwargs.update({'request': self.request})
        return kwargs

    def get_success_url(self):
        # This is in a method instead of the success_url attribute
        # because doing it as an attribute would involve a
        # module-level call to reverse(), creating a circular
        # dependency between the URLConf (which imports this module)
        # and this module (which would need to access the URLConf to
        # make the reverse() call).
        return reverse('contact_form_sent')



Add this to URL patterns:
  url(r'^report/', ReportFormView.as_view(), name='report_form'),



and in forms.py subclass like this:
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'

And the template, thanks to you is easy as pie:
report.html:
{% extends 'base.html' %}

{% block body_block %}
<h2>Contact Form</h2>
  <p>To send us a message fill out the below form.</p>
        <form method="post">{% csrf_token %}
{{ form.as_p }}
            <input type="submit" value="Submit">
  </form>
{% endblock %}



Now I just need to figure out how to pre-fill.

-- 
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/f0107dff-039b-446d-9f33-aa7f0cd640e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to