0

I have a context processor where I'm trying to override get_and_delete_messages

from forum.user_messages import get_and_delete_messages  
def user_messages (request):  
    """
    Returns session messages for the current session.  
    """
    messages = request.user.get_and_delete_messages()  
    return { 'user_messages': messages }  

It's not picking up a user message that I can see in the debugging session:

ipdb> request.session['messages']  
["only site Admins can use that feature."]  

The app seems to be calling the get_and_delete_messages from the User model @ django.contrib.auth.models:

Instead of the method I imported.

How do I get the correct model called?

BryanWheelock
  • 12,146
  • 18
  • 64
  • 109

1 Answers1

1

When you import get_and_delete_messages, you are importing a function with that name. request.user.get_and_delete_messages is still bound to the same function implementation that it was bound to before.

mipadi
  • 398,885
  • 90
  • 523
  • 479