title: Rendering and customising a django form in the template
body: <p>So I've managed to output my form to the template. But i'm having a little trouble with one of the forms as the frontend styling has already been done. I'd just like to be able to output the label names etc within in the HTML that already exists. I can get the form the output to the template using the following:</p>
  
  <pre><code>&lt;form method="post"&gt;
      {% csrf_token %}
          {{enquiry_form.as_ul}}                          
              &lt;button type="submit" class="submit softcolor"&gt;
                  &lt;span&gt;Submit&lt;/span&gt;
              &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>However, I have a ManytoMany field on the model where I would like users to be able to tick multiple options with a checkbox. When i output the above I get a select box as with a list of the categories it's pulling through.</p>
  
  <pre><code>{% csrf_token %}
      {% for fields in enquiry_form %}
          &lt;div class="block-365 center clearfix"&gt;
              &lt;label&gt;{{fields.label}}&lt;/label&gt;
              &lt;div class="input-line"&gt;
                  &lt;input name=""&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      {% endfor %}
  </code></pre>
  
  <p>So i can do something like the above, which works fine. But for some reason the CSRF protection stops working. I also need to be able to be able to access the items in the Brochure model(The manyToMany field).</p>
  
  <p>Here the code I have so far:</p>
  
  <p>forms.py</p>
  
  <pre><code>from django.forms import ModelForm
  from django import forms
  
  from contact_enquiries import models
  
  class ContactEnquiryForm(ModelForm):
  
      class Meta:
          model = models.ContactForm
          fields=('name','email','company', 'subject', 'message')
  
  
  class BrochureRequestForm(ModelForm):
  
      class Meta:
          model = models.ContactForm
          fields = ('name', 'email', 'company', 'address', 'brochure',)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>from contact_enquiries import forms
  from django.shortcuts import render
  from django.http import HttpResponseRedirect
  
  
  def contact(request):
      if request.method == 'POST':
          form = forms.ContactEnquiryForm(request.POST)
          en_form = forms.BrochureRequestForm(request.POST)
  
          print(request.POST)
          if form.is_valid():
              #print "Form looks good!"
              #e = models.ContactEnquiry(form.cleaned_data)
              #e.save()
              form.save()
              return HttpResponseRedirect('/thanks/')
          else:
              form = forms.ContactEnquiryForm()
              en_form = forms.BrochureRequestForm()
  
      return render(request, 'contact.html', {
              'contact_form' : form,
              'enquiry_form' : en_form,
              })
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>class ContactForm(models.Model):
      name = models.CharField(max_length="300")
  
      company = models.CharField(max_length="200")
  
      email = models.CharField(max_length="300")
  
      subject = models.TextField()
  
      message = models.TextField()
  
      address = models.TextField()
  
      brochure = models.ManyToManyField("Brochure", blank=True)
  
      def __unicode__(self):
          self.name
  
      class Meta:
          verbose_name = "Contact Enquiry"
          verbose_name_plural = "Contact Enquiries"
  
  
  class Brochure(models.Model):        
      title = models.CharField(max_length="200")
  
      def __unicode__(self):
          self.title
  
      class Meta:
          verbose_name = "Brochure"
          verbose_name_plural = "Brochures"
  </code></pre>
  
  <p>And the HTML is displayed above. Not sure which the best approach is when outputting the form to the template, but i need to be able to use the HTML/CSS suplied to save me time re-doing it. Also I need to able to get the checkbox working on the Brochure form. As the idea is when they fill in the form they can choose which PDF they would like to be sent.</p>
  
  <p>Any questions please ask!</p>