I have a CreateView class where i set the success url like this
class ListCreateView(CreateView):
model = List
fields = "_all_"
success_url = "list"
after submitting the form Its going to
http://127.0.0.1:8000/home/create_list/list
which doesnt exist
I want it to go to
http://127.0.0.1:8000/home/list
can anyone help with some suggestions? I tried reverselazy but that brings up another big error. and im a noob.
CodePudding user response:
If you want to go to /home/list
that should be your success_url
.
And if you have named your views, you can do it by reverse_lazy()
.
Something like:
class ListCreateView(CreateView):
model = List
fields = "_all_"
success_url = "/home/list/"
# or if you named your urls in urls.py
success_url = reverse_lazy("home:list")