title: Django: dynamic success_url results in "'NoneType' object has no attribute 'find'"
body: <p>I would like to redirect the <code>success_url</code> to the same form after the form was submitted and valid. <a href="https://groups.google.com/forum/?fromgroups=#!topic/pyweb-il/I6iuyHLhhiE" rel="nofollow">Online</a> I found a description of a solution, however this solution and my other code option generate the same error message.</p>
  
  <pre><code>Exception Value: 'NoneType' object has no attribute 'find'
  </code></pre>
  
  <h1>urls.py</h1>
  
  <pre><code>url(r'^pictures/(?P&lt;id&gt;\d+)/$', PictureUpload.as_view(), name='picture_upload'),
  ...
  </code></pre>
  
  <h1>1st views.py option</h1>
  
  <p>copies the existing link path</p>
  
  <pre><code>class PictureUpload(FormView):
      form_class = PictureForm
      template_name = 'picture_upload.html'   
      def get_success_url(self):
          success_url = lambda self: self.request.path
  </code></pre>
  
  <h1>2nd views.py option</h1>
  
  <p>recreates the link path based on the reverse url plus the id</p>
  
  <pre><code>class PictureUpload(FormView):
      form_class = PictureForm
      template_name = 'picture_upload.html'   
      def get_success_url(self):
          success_url = reverse('picture_upload', 
              kwargs={'id': self.kwargs.get('id', None)})
  </code></pre>
  
  <h1>Both options end up in the same traceback.</h1>
  
  <pre><code>Request Method: POST
  Request URL: http://127.0.0.1:8000/pictures/2/
  
  Django Version: 1.5.1
  Python Version: 2.7.1
  Installed Applications:
  ('django.contrib.admin',
   'django.contrib.admindocs',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.gis',
   'django.contrib.humanize',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'django.contrib.admin',
   'django.contrib.admindocs',
   'picture',
   'debug_toolbar')
  Installed Middleware:
  ('django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'debug_toolbar.middleware.DebugToolbarMiddleware')
  
  
  Traceback:
  File "/Users/Development/virtual-re/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
    115.                         response = callback(request, *callback_args, **callback_kwargs)
  File "/Users/Development/virtual-re/lib/python2.7/site-packages/django/views/generic/base.py" in view
    68.             return self.dispatch(request, *args, **kwargs)
  File "/Users/Development/virtual-re/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
    86.         return handler(request, *args, **kwargs)
  File "/Users/Development/virtual-re/lib/python2.7/site-packages/django/views/generic/edit.py" in post
    165.             return self.form_valid(form)
  File "/Users/Development/project/apps/picture/picture_views.py" in form_valid
    180.         return super(PictureUpload, self).form_valid(form)
  File "/Users/Development/virtual-re/lib/python2.7/site-packages/django/views/generic/edit.py" in form_valid
    65.         return HttpResponseRedirect(self.get_success_url())
  File "/Users/Development/virtual-re/lib/python2.7/site-packages/django/http/response.py" in __init__
    388.         parsed = urlparse(redirect_to)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py" in urlparse
    134.     tuple = urlsplit(url, scheme, allow_fragments)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py" in urlsplit
    173.     i = url.find(':')
  
  Exception Type: AttributeError at /pictures/2/
  Exception Value: 'NoneType' object has no attribute 'find'
  </code></pre>