Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.42 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Can I pass non-URL definition view keyword to a view function when redirecting?
  2. NoReverseMatch at /natrium/script/4c55be7f74312bfd435e4f672e83f44374a046a6aa08729aad6b0b1ab84a8274/
  3.  
  4. Reverse for 'run_details' with arguments '()' and keyword arguments '{'script_text': u'print "happy"', 'run_id': '6b2f9127071968c099673254fb3efbaf'}' not found.
  5.        
  6. run_id = new_run.run_id
  7. if not run_id:
  8. raise AssertionError("bad run id")
  9.  
  10. # I tried with args=[run_id, clean['script_text']] too
  11. return HttpResponseRedirect(reverse('run_details', kwargs={'run_id':run_id, 'script_text':clean['script_text']}))
  12.        
  13. def run_details(request, run_id, script_text):
  14.     """
  15.     Displays the details of a given run.
  16.     """
  17.     run = Run(run_id)
  18.     run.update(request.user)
  19.  
  20.     codebundle = CodeBundle(run.cbid)
  21.     codebundle.update(request.user)
  22.  
  23.     return render_response(request, "graphyte/runs/run_script.html",
  24.                            {'run':run, 'codebundle':codebundle, 'files':run.artifacts, 'bundle':codebundle,
  25.                             'source_code': script_text
  26.                            })
  27.        
  28. urlpatterns = patterns("webclient.apps.codebundles.views",
  29.     # many.....
  30.     url(r"^cb/newfolder/$", 'codebundle_newfolder', name="codebundle_newfolder"),
  31. )
  32.  
  33. urlpatterns += patterns('webclient.apps.runs.views',
  34.         url(r"^run_details/(?P<run_id>w+)/$", 'run_details', name="run_details"),)
  35.        
  36. HTTP/1.1 302 Found
  37. Location: http://www.example.com/new-url/