Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress "?next=blah" behavior in django's login_required decorator

I love django's @login_required decorator, but there's one thing I can't figure out how to make it do.

If an unauthenticated user tries visits a @login_required page (e.g. "/private-stuff/"), I want to kick them back to the home page (e.g. "/home/"). But I don't want to append a "?next=" argument to the url. In other words, I just want to redirect to "/home/", not "/home/?next=/private-stuff/".

How can I do that? Is there a better way than just writing my own decorator?

like image 214
Abe Avatar asked Jun 08 '12 14:06

Abe


1 Answers

Isn't it just simply as:

@decorators.login_required(redirect_field_name=None)
like image 66
Danosaure Avatar answered Sep 23 '22 16:09

Danosaure