There is a project setup with Django 1.6 and Django allauth . when the user is logged in to django, saves a message to enter the user's session and its stack. While the user has reached any message structure included in the message, a login message appears with another message.
For this reason, I want to remove the input message from the message queue after user login.
I tried to delete the login message for django and allauth user_logged_in , but I found that the message was not created there.
Sample message deletion code below:
# from allauth.account.signals import user_logged_in # First I tried allauth signal above. from django.contrib.auth.signals import user_logged_in @receiver(user_logged_in) def user_logged_in_(request, **kwargs): storage = messages.get_messages(request) storage.used = True
Edit: The workaround below works. But I believe that this is the wrong way to do it.
After that, I decided to make a workaround. After the user logs in, the user is redirected to the index view. I removed the signal and added the storage.used = True method in the index view. Also it does not work.
def clear_messages(request): storage = messages.get_messages(request) storage.used = True def index(request): clear_messages(request) return render_to_response('website/index.html', {}, context_instance=RequestContext(request, {}))
source share