Hi Martin,

There are (as of Django 1.4) already two solutions to this:

1 - override get_success_url(). the default behaviour of this method is to just 
return self.success_urll, but obviously it can be modified to return whatever 
you like

2 - use reverse_lazy (Django 1.4)  instead of reverse to delay the evaluation 
until after the urlconf has been initialised.

I don't think there's a real benefit to having a third approach.


Regards,
Andrew Ingram


On 8 Apr 2012, at 22:12, Martin Tiršel wrote:

> Hello,
> 
> I just started to use class based views and I came to the CreateView and 
> success_url argument. This argument has to be string what leads to typing 
> URLs in views instead of using reverse() function (you have no access to urls 
> through reverese() in view initialization). I think (if there is no better 
> way) that this parameter should accept callable too and something like this 
> would be possible:
> 
> class MyView(CreateView):
>    success_url = lambda: reverse(
>        'foo:bar'
>    )
> 
> Should I create a feature request ticket or should I read the docs more 
> carefully? :)
> 
> Kind regards,
> Martin Tirsel
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/django-developers?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to