I'm having this problem with this use of the get_success_url() in my CreateView class:
def get_success_url(self):
search = searchViews.getIndexInstance()
search.mainfunc(self.contentForSearch, self.discussion.pk)
return HttpResponseRedirect(reverse('discussion-detail', kwargs={'slug':self.discussion.slug}))
Here's the complete error stacktrace:
Traceback:
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/views/generic/base.py" in view
71. return self.dispatch(request, *args, **kwargs)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
34. return bound_func(*args, **kwargs)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
22. return view_func(request, *args, **kwargs)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
30. return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/nithin/djangopro/viewanalyse/discussion/views.py" in dispatch
30. return super(LoggedInMixin, self).dispatch(*args, **kwargs)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
89. return handler(request, *args, **kwargs)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/views/generic/edit.py" in post
249. return super(BaseCreateView, self).post(request, *args, **kwargs)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/views/generic/edit.py" in post
215. return self.form_valid(form)
File "/home/nithin/djangopro/viewanalyse/discussion/views.py" in form_valid
374. return super(DiscussionContentUpdateCreateView, self).form_valid(form)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/views/generic/edit.py" in form_valid
194. return super(ModelFormMixin, self).form_valid(form)
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/views/generic/edit.py" in form_valid
108. return HttpResponseRedirect(self.get_success_url())
File "/home/nithin/djangopro/djangoenv/local/lib/python2.7/site-packages/django/http/response.py" in __init__
456. raise DisallowedRedirect("Unsafe redirect to URL with protocol '%s'" % parsed.scheme)
Exception Type: DisallowedRedirect at /discussion/discussion-content-update/why-i-believe-in-reincarnation-g-hijo-2015-08-09-162236316999/
Exception Value: Unsafe redirect to URL with protocol 'content-type'
What's the cause and how can I fix this?
The get_success_url method should return a URL, not an HTTP response.
def get_success_url(self):
search = searchViews.getIndexInstance()
search.mainfunc(self.contentForSearch, self.discussion.pk)
return reverse('discussion-detail',kwargs={'slug':self.discussion.slug})
It's not clear what the first two lines are for, they don't seem to be used by the reverse() call.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With