Friday, January 10, 2014

using success_url

I can't seem to find success using success_url

If I try this in my urls.py file

url(r'^step2/', AnswersCreate.as_view(success_url='/requestform/success'), name='answers'),

and then in my view:

def form_valid(self, form):
        obj = form.save(commit=False)
        obj.created_by = self.request.user
        obj.save()
        return HttpResponseRedirect(self.get_success_url())

I get a successful save but it does not take me to the next url defined in success_url

Is there another way to do it, or what am I doing wrong?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/775978f7-774f-4ef5-b12e-9e97f3c3864a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate