title: How to display django form in modal window?
body: <p>I saw this <a href="https://stackoverflow.com/questions/11276100/how-do-i-insert-a-django-form-in-twitter-bootstrap-modal-window">post</a>, but it did not help me</p>
  
  <p>In the modal window, the form is not displayed.</p>
  
  <p>View:</p>
  
  <pre><code>class CreateOrder(FormView):
      template_name = 'toner/add_order.html'
  
      form_class = OrderForm
      success_url = '/toner/'
  
      def form_valid(self, form):
          form.save()
          return super(CreateOrder, self).form_valid(form)
  </code></pre>
  
  <p>add_order.html:</p>
  
  <pre><code>&lt;div id="order" class="modal fade" role="dialog"&gt;
  &lt;div class="modal-dialog"&gt;
      &lt;div class="modal-content"&gt;
          &lt;div class="modal-body"&gt;
              &lt;div class="container txt-box"&gt;
                  &lt;form action="{% url 'add_order' %}" role="form" method="post"&gt;
                      {% csrf_token %}
                      {{ form.media }}
                      {{ form.address }}
                      {{ form.room }}
                      {{ form.count }}
                      &lt;button class="btn btn-success" type="submit"&gt;
                          Done
                      &lt;/button&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>main_page.html:</p>
  
  <pre><code>{% extends 'toner/base.html' %}
  
  {% block main_page %}
  
  ....
  
  &lt;div&gt;
      &lt;button class="btn btn-primary" data-toggle="modal" data-
      target="#order"&gt;
          Order
      &lt;/button&gt;
      {% include "toner/add_order.html" %}
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  
  <p>urls:</p>
  
  <pre><code>url(r'add_order/$', CreateOrder.as_view(), name='add_order'),
  </code></pre>
  
  <p>If I go directly to the url (/add_order) it works. I can see the form. But from main_page.html the modal window is empty. Maybe someone has solved for themselves such a task?</p>
  
  <p>UPDATE</p>
  
  <pre><code>from django.views.generic import ListView, FormView
  from .models import Printer, Order
  from .forms import OrderForm
  
  
  class MainPageView(ListView):
      template_name = 'toner/main_page.html'
  
      model = Printer
  
      def get_context_data(self, **kwargs):
          context = super(MainPageView, self).get_context_data(**kwargs)
          context['printer'] = Printer.objects.all()
          context['order'] = Order.objects.all()
          return context
  
  
  class CreateOrder(FormView):
      template_name = 'toner/add_order.html'
  
      form_class = OrderForm
      success_url = '/toner/'
  
      def form_valid(self, form):
          form.save()
          return super(CreateOrder, self).form_valid(form)
  </code></pre>