I have a view:
def create_something(request):
...
I want to redirect to login if a person isn't logged in. Normally I'd use:
@login_required
def create_something(request):
...
but ... I want to add a message before the redirect.
I wanted to do it like this:
def create_something(request):
if not request.user.is_authenticated:
messages.info(request, 'You must be logged in to create a thing .')
return redirect('login')
...
However, that doesn't include a ?next in the url to go back to the page I was going to.
So my question is:
How would you manually redirect back to the login page WITH a manually added ?next query?