title: How do I make my post form handling more flexible
body: <p>I have written what I hope to be a re-usable Django app, but I have a bit of a conundrum on how to make the post form handling flexible. The simplified version of my view code looks like:</p>
  
  <pre><code>def do_form(request, entity_id, template_name, success_url):
  
      form = MyForm(request.POST or None)
  
      if request.method =='POST':
          if form.is_valid():
  
              #do some business logic
  
              return HttpResponseRedirect(finished_url)
      return render_to_response(template_name, 
                                {'form': form},
                               context_instance=RequestContext(request))
  </code></pre>
  
  <p>I have followed the advice in James Bennets book  "Practical Django Projects" and so you can now configure the template and the success url in the url conf, so for example my url conf could look like this:</p>
  
  <pre><code>urlpatterns = patterns('myapp.views',
  
  
            url(r'^do/(?P&lt;entity_id&gt;\d+)/$', 
            view = 'do_form',
            name = 'do_form_view',
            kwargs={'template_name':'form.html',
                      'success_url':'/finish/'},),
  
            url(r'^finish/$', 
            view = 'finish',
            name = 'finish_view')
  )
  </code></pre>
  
  <p>This is all very well and good but when I have come to use this in my real world application I find myself in a situation that this form sits in the middle of some workflow, and I want the success url to be something like <code>/continue/&lt;workflow_id&gt;/</code> , and the problem is that you can only have a hardcoded url in the url conf, and the workflow_id will vary every time I hit the do_form code.</p>
  
  <p>Can any one suggest a way to get around this?</p>