title: django - What does this line achieve here?
body: <p>I'm following a tutorial on effectivedjango.com, and this is the code they have:</p>
  
  <p>views.py:</p>
  
  <pre><code>class CreateContactView(CreateView):
      model = Contact
      template_name = 'edit_contact.html'
      fields = '__all__'   #this is needed for error msg Using ModelFormMixin (base class of CreateContactView) without the 'fields' attribute is prohibited.
      def get_success_url(self):
          return reverse('contacts-list')
      def get_context_data(self, **kwargs):
          context = super(CreateContactView, self).get_context_data(**kwargs)
          context['action'] = reverse('contacts-new')   
          return context
  
  class UpdateContactView(UpdateView):
      model = Contact
      template_name = 'edit_contact.html'
      fields = '__all__'
      def get_success_url(self):
          return reverse('contacts-list')
      def get_context_data(self, **kwargs):
          context = super(UpdateContactView, self).get_context_data(**kwargs)
          context['action'] = reverse('contacts-edit', kwargs={'pk' : self.get_object().id})
          return context
  </code></pre>
  
  <p>urls.py:</p>
  
  <pre><code>url(r'^$', contacts.views.ListContactView.as_view(),
      name='contacts-list',),
  url(r'^new$', contacts.views.CreateContactView.as_view(),
      name='contacts-new',),
  url(r'^edit/(?P&lt;pk&gt;\d+)/$', contacts.views.UpdateContactView.as_view(),
      name='contacts-edit',),
  </code></pre>
  
  <p>contact_list.html:</p>
  
  <pre><code>{% block content %}
  &lt;h1&gt;Contacts&lt;/h1&gt;
  
  &lt;ul&gt;
    {% for contact in object_list %}
      &lt;li class="contact"&gt;
        &lt;a href="{{ contact.get_absolute_url }}"&gt;{{ contact }}&lt;/a&gt;
        (&lt;a href="{% url "contacts-edit" pk=contact.id %}"&gt;edit&lt;/a&gt;)
      &lt;/li&gt;
    {% endfor %}
  &lt;/ul&gt;
  
  &lt;a href="{% url "contacts-new" %}"&gt;Add contact&lt;/a&gt;
  {% endblock %}
  </code></pre>
  
  <p>edit_contact.html:</p>
  
  <pre><code>{% block content %}
  
  {% if contact.id %}
  &lt;h1&gt;Edit Contact&lt;/h1&gt;
  {% else %}
  &lt;h1&gt;Add Contact&lt;/h1&gt;
  {% endif %}
  
  &lt;form action="{{ action }}" method="POST"&gt;
  {% csrf_token %}
  &lt;ul&gt;
  {{ form.as_ul }}
  &lt;/ul&gt;
  &lt;input id="save_contact" type="submit" value="Save" /&gt;
  &lt;/form&gt;
  
  &lt;a href="{% url "contacts-list" %}"&gt;Back to list&lt;/a&gt;
  {% if contact.id %}
  &lt;a href="{% url "contacts-delete" pk=contact.id %}"&gt;Delete&lt;/a&gt;
  {% endif %}
  {% endblock %}
  </code></pre>
  
  <p>Why does the line <code>context['action'] = reverse('contacts-edit', kwargs={'pk' : self.get_object().id})</code> in <code>views.py</code> look like its calling itself? </p>
  
  <p>What I mean is, this action is called when the submit button is pressed in the <code>contact-edit</code> template, correct? So it starts there, and it is reverse-calling <code>contact-edit</code> which is itself, right? </p>
  
  <p>What am I not seeing here?</p>
  
  <p>Thank you for all your help.</p>