title: Passing Id from CreateView to another function after creating the object
body: <p>I am creating a Payment object using Django <code>CreateView</code> then I want to pass the <code>id</code> of this object to another view function to make and display some calculations on another template. how can i do that?</p>
  
  <p>views.py:</p>
  
  <pre><code>class CreatePayment(CreateView):
      template_name = "inventory/new_payment.html"
      success_url = reverse_lazy('inventory:payments_page')
      model = Payments
      fields = ('payment_number', 'customer','agent', 'amount')
  </code></pre>
  
  <p>html:</p>
  
  <pre><code>&lt;body&gt;
  
  &lt;form action="{% url 'inventory:new_payment'%}" method="post"&gt;
      {% csrf_token %}
      {{form}}
  
      &lt;button type="submit", value="Add"&gt;Add&lt;/button&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p>urls: </p>
  
  <pre><code>url(r'newpayment/$', CreatePayment.as_view(), name='new_payment')
  </code></pre>