title: Django form to indicate input type
body: <p>Another basic question I'm afraid which I'm struggling with.  I've been through the various Django documentation pages and also search this site. The only thing I have found on here was back in 2013 which suggested setting up a custom filter template.</p>
  
  <p>Anyhow, I'm trying to generate my own form instead of using Django's own way of generating it through {{ form }}.  This is simply so I can control the way the form is presented.</p>
  
  <p>I've worked out various ways to access the required information such as (within my for item in form loop);</p>
  
  <ul>
  <li>item.help_text</li>
  <li>item.label_tag</li>
  <li>item.id_for_label</li>
  </ul>
  
  <p>I'm trying to identify the item type so I can use the correct input type, however I'm struggling to workout what item.xxxx should be.  Since this is correctly displayed through {{ form }} I am making an assumption that this information is available somewhere in the form, just struggling to find out how to access it so I can identify the correct input type.  I'm doing this manually so I can use the correct Bootstrap styles to display the input fields.</p>
  
  <p>Any assistance would be appreciated (or just pointing in the right direction).  I'm very new to this so apologies for my very basic questions, its difficult without knowing someone I can just go an ask these questions to.</p>
  
  <p>Regards</p>
  
  <p>Wayne</p>
  
  <p>Not sure if you need it but here is some code;</p>
  
  <p>Form:</p>
  
  <pre><code>class NewsForm(ModelForm):
      class Meta:
          model = News_Article
          exclude = ('news_datetime_submitted', 'news_yearmonth', )
          labels = {
              'news_title': _('Enter News Title'),
          }
          help_texts = {
              'news_title': _('Enter a title to give a short description of what the news is.'),
          }
          error_messages = {
              'news_title': {
                  'max_length': _("News title is too long."),
              },
          }
  </code></pre>
  
  <p>View (not worked on the POST bit yet, this is just what's from the Django documentation, POST is my next thing to work out)</p>
  
  <pre><code>def create(request, dataset):
      if dataset not in ['news', 'announcement']:
          return HttpResponseRedirect(reverse('pages'))
      rDict = {}
      if request.method == 'POST':
          if dataset == "news":
              form = NewsForm(request.POST)
          elif dataset == "announcement":
              form = AnnouncementForm(request.POST)
          if form.is_valid():
              return HttpResponseRedirect('/home/')
          else:
              pass
      else:
          announcement = get_announcement()
          if not announcement == None:
              rDict['announcement'] = announcement
          if dataset == "news":
              rDict['form'] = NewsForm()
              rDict['branding'] = {'heading': 'Create News Item', 'breadcrumb': 'Create News', 'dataset': 'create/' + dataset + '/'}
          elif dataset == "announcement":
              rDict['form'] = AnnouncementForm()
              rDict['branding'] = {'heading': 'Create Announcement', 'breadcrumb': 'Create Announcement', 'dataset': 'create/' + dataset + '/'}
          rDict['sitenav'] = clean_url(request.path, ['"', "'"])
          rDict['menu'] = Menu.objects.all().order_by('menu_position')
  #        pdb.set_trace()
          return render(request, 'en/public/admin/admin_create.html', rDict)
  </code></pre>
  
  <p>Template code</p>
  
  <pre><code>&lt;form action="/siteadmin/{{ branding.dataset }}" method="post"&gt;
      {% csrf_token %}
      {% for item in form %}
          &lt;div class="row"&gt;
              &lt;div class="col-xs-2 col-md-2"&gt;
              &lt;/div&gt;
              &lt;div class="col-xs-4 col-md-4"&gt;
                  &lt;div class="panel-title pull-right"&gt;
                      {% if item.help_text %}
                        &lt;img src="/static/images/info.png" height="20" width="20" aria-hidden="true" data-toggle="popover" title="{{ item.help_text }}"&gt;&amp;nbsp
                      {% endif %}
                      {{ item.label_tag }}
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="col-xs-4 col-md-4"&gt;
                  &lt;div class="input-group"&gt;       
                      &lt;input type="{{ item.widget }}" class="form-control" placeholder="" aria-describedby="{{ item.id_for_label }}"&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="col-xs-2 col-md-2"&gt;
                  {% if forloop.last %}
                      &lt;input type="submit" value="Submit" /&gt;
                  {% endif %}
              &lt;/div&gt;          
          &lt;/div&gt;
      {% endfor %}
  &lt;/form&gt;
  </code></pre>