success_url in UpdateView, based on passed value

后端 未结 5 1097
我在风中等你
我在风中等你 2020-12-23 20:52

How can I set success_url based on a parameter?
I really want to go back to where I came from, not some static place. In pseudo code:

url(r         


        
5条回答
  •  一向
    一向 (楼主)
    2020-12-23 21:13

    Create a class MyUpdateView inheritted from UpdateView and override get_success_url method:

    class MyUpdateView(UpdateView):
        def get_success_url(self):
            pass #return the appropriate success url
    

    Also i like to pass such parameters like template_name and model inside of inheritted class view, but not in .as_view() in urls.py

提交回复
热议问题