I am trying to set the success_url on a django class based UpdateView but cannot get it to work. I have tried the syntax suggested in the docs
success_url="/polls/%(slug)s/"
But it is not working. How can I access the model fields in the success_url?
This relies on object field attributes. In the example you’ve posted, the model should have a slug field.
For related fields:
You can try using django’s __ notation for related objects (e.g:
user__username) insuccess_url, not sure if it’ll work.IMO in such cases a better practice is overriding
get_success_url(), and returning the url taking into accountself.object.