'How to set LOGIN_URL variable in Django settings so it doesn't redirect anywhere while not logged in

When trying to access url get_room_messages if user is not logged in @login_required redirects him to: /accounts/login/?next=/get_room_messages (as specified in docs)

I want it to do nothing (or redirect to the original url, in this example /get_room_messages). I don't want to hardcode it like @login_required(login_url='/get_room_messages'), ideal solution would be to get somehow original url and pass it into @login_required() decorator.

@login_required() 
def get_room_messages(request):
    user_id = request.user.user_ID
    user = get_object_or_404(CustomUser, pk=user_id)

Thank you for help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source