title: Django: can't display formset and form proper
body: <p>I'm making site for applications. And have two models: Applications and Guests and they have manytomany connection, because application can have 2 or more guests and 1 guest may be in many applications.</p>
  
  <p>For making applications i use formset_factory with delete option. The problem is - I can't find any good examples with code for manytomanyfield and formset and I can't bound them in template. I can't display the table at all. Here's the code.</p>
  
  <p>p.s. don't pay attention to cyrillic symbols</p>
  
  <p>models</p>
  
  <pre><code>class Guests(models.Model):
  unique_number_guest = models.IntegerField(unique=True, primary_key=True, verbose_name='№')
  organisation = models.CharField(max_length=100, verbose_name='Организация', null=True)
  full_name = models.CharField(max_length=100, verbose_name='ФИО')
  position = models.CharField(max_length=100, verbose_name='Должность', blank=True, null=True)
  chosen = models.BooleanField(default=False, verbose_name='Выбран')
  class Applications(models.Model):
  ntc_cabins = (
      ('2-5', '2-5'),
      ('2-10', '2-10'),
      ('2-12', '2-12'),
  )
  ntc_blocks = (
      ('ЦОК', 'ЦОК'),
      ('БМЗ', 'БМЗ')
  )
  
  unique_number_app = models.IntegerField(unique=False, null=True)
  visit_date = models.DateField(default=date.today()+timedelta(days=1), verbose_name='Дата:')
  visit_time = models.TimeField(default='12:00', verbose_name='Время:')
  cabin = models.CharField(max_length=5, verbose_name='Кабинет:', choices=ntc_cabins, default='2-12')
  block = models.CharField(max_length=10, verbose_name='Корпус:', choices=ntc_blocks, default='ЦОК')
  author = models.CharField(max_length=100, verbose_name='Автор:')
  guests = models.ManyToManyField(Guests)
  </code></pre>
  
  <p>views</p>
  
  <pre><code>def ApplicationFormation(request):
  form = ApplicationsForm(request.POST)
  form.guest_instanses = GuestsFormSet(request.POST)
  if request.method == "POST":
      if form.is_valid():
          applications = Applications()
          applications.cabin = form.cleaned_data['cabin']
          applications.save()
          for person in form.guests_visited:
              guest = Guests()
              guest.full_name = person['full_name']
              guest.organisation = person['organisation']
              guest.position = person['position']
              guest.save()
              applications.guests.add(guest)
          return HttpResponse('good job')
      print(form.errors)
  else:
      formset = GuestsFormSet()
  print('FORMSET:', formset)
  return render(request, 'myprofile/applications_form.html', {'form': form, 'fomset': formset})
  </code></pre>
  
  <p>forms</p>
  
  <pre><code>class GuestsForm(ModelForm):
  organisation = forms.CharField()
  full_name = forms.CharField()
  position = forms.CharField()
  class Meta:
      model = Guests
      exclude = ('unique_number_guest', 'chosen',)
  GuestsFormSet = formset_factory(GuestsForm, extra=1, can_delete=True)
  
  class ApplicationsForm(ModelForm):
  visit_date = forms.DateField()
  visit_time = forms.TimeField()
  cabin = forms.CharField()
  block = forms.CharField()
  guests = GuestsFormSet()
  
  
  class Meta:
      model = Applications
      exclude = ('unique_number_app', 'author', 'guests', 'ntc_cabin')
  </code></pre>
  
  <p>and template</p>
  
  <pre><code>{% extends "base.html" %}
  {% load static %}
  {% block title %}{% endblock %}
  {% block content %}
  
  
  
  &lt;h2&gt;Заявка на пропуск&lt;/h2&gt;
  &lt;hr&gt;
  &lt;div class="col-md-4"&gt;
      &lt;form action="" method="post" class=""&gt;
          {% csrf_token %}
          {{ form.as_p }}
  
  
          &lt;h3&gt;Гости&lt;/h3&gt;
          &lt;table id="table-guests"&gt;
              {{ formset.management_form }}
              {% for form in formset %}
                  {% if forloop.first %}
                      &lt;thead&gt;
                      &lt;tr&gt;
                          {% for field in form.visible_fields %}
                              &lt;th&gt;{{ field.label|capfirst }}&lt;/th&gt;
                          {% endfor %}
                      &lt;/tr&gt;
                      &lt;/thead&gt;
                  {% endif %}
                  &lt;tr class="{% cycle row1 row2 %} formset_row"&gt;
                      {% for field in form.visible_fields %}
                          &lt;td&gt;
                              {# Include the hidden fields in the form #}
                              {% if forloop.first %}
                                  {% for hidden in form.hidden_fields %}
                                      {{ hidden }}
                                  {% endfor %}
                              {% endif %}
                              {{ field.errors.as_ul }}
                              {{ field }}
                          &lt;/td&gt;
                      {% endfor %}
                  &lt;/tr&gt;
              {% endfor %}
          &lt;/table&gt;
          &lt;input type="submit" value="Сохранить и сформировать заявку"/&gt; &lt;a href="{% url 'applications-list' %}"&gt;Назад&lt;/a&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="{% static 'formset/jquery.formset.js' %}"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $('.formset_row').formset({
          addText: 'добавить',
          deleteText: 'удалить',
          prefix: 'Guests'
      });
  &lt;/script&gt;
  </code></pre>