I know that HttpResponseRedirect accepts only one parameter - the URL. But there are cases when I want to redirect with the display of an error message.
I read this post: How to pass information using HTTP redirection (in Django) , and there were a lot of good suggestions. I really don't want to use a library that I don't know how it works. I do not want to rely on posts that, according to Django docs, will be deleted. I was thinking about using sessions. I also like the idea of ββpassing it to a URL, for example:
return HttpResponseRedirect('/someurl/?error=1')
and then with some code from the error code to the message. Is it good practice to have a global structure similar to a map that hardcodes these error messages or is there a better way?
Or do I just need to use a session
EDIT: I worked using the session. Is it really good practice to be busy with this?
source
share