title: How can I call multiple views in one url address in Django?
body: <p>I'm trying to show forms defined by new_measurement on index.html, but I only manage to get <code>IndexView()</code> to work. I tried various combinations between <code>IndexView()</code> and <code>new_measurement()</code>, but those didn't work out at all. I know that <code>IndexView()</code> doesn't pass anything related to <code>new_measurement()</code>, and <code>new_measurement()</code> isn't called, which is the core of my problem. I'd really appreciate if someone more experienced with Django could tell me what I could, or should do. Thank you.</p>
  
  <p>Here's my <strong>views.py</strong>:</p>
  
  <pre><code>from django.shortcuts import render
  from django.utils import timezone
  from .models import Measurement
  from .forms import MeasurementForm
  from django.views import generic
  
  
  class IndexView(generic.ListView):
      model = Measurement
      context_object_name = 'measurement_list'
      template_name = 'index.html'
      queryset = Measurement.objects.all()
  
  
  def new_measurement(request):
      if request.method == "POST":
          form = MeasurementForm(request.POST)
          if form.is_valid():
              measurement = form.save(commit=False)
              measurement.measurement_date = timezone.now()
              measurement.save()
      else:
          form = MeasurementForm()
  
      return render(request, 'index.html', {'form': form})
  </code></pre>
  
  <p><strong>urls.py</strong>:</p>
  
  <pre><code>from django.urls import path
  from . import views
  
  
  urlpatterns = [
      path('', views.IndexView.as_view(), name='index'),
  ]
  </code></pre>
  
  <p><strong>forms.py</strong>:</p>
  
  <pre><code>class MeasurementForm(forms.ModelForm):
      class Meta:
          model = Measurement
          fields = ('measurement_value', 'measurement_unit')
  </code></pre>
  
  <p><strong>index.html</strong>:</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block content %}
      &lt;h1&gt;Climate Measurement Tool&lt;/h1&gt;
  
      &lt;h2&gt;Add a new measurement&lt;/h2&gt;
      &lt;form method="POST" class="post-form"&gt;
          {% csrf_token %}
          {{ form.as_p }}
          &lt;button type="submit" class="save"&gt;Add&lt;/button&gt;
      &lt;/form&gt;
  
      &lt;h2&gt;Measurements&lt;/h2&gt;
      {% if measurement_list %}
      &lt;ul&gt;
          {% for measurement in measurement_list %}
          &lt;li&gt;
              &lt;p&gt;{{ measurement }}&lt;/p&gt;
          &lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
      {% else %}
          &lt;p&gt;No measurements yet&lt;/p&gt;
      {% endif %}    
  {% endblock %}
  </code></pre>