tags:

views:

60

answers:

1

Forgive me if this question makes little sense; I have had little sleep as of late.

I want to send a notification to the user whenever a signal fires via django's messages module, but I am at a loss as to how to pass the request object to the messages.success method.

I'm doing this because whenever a user gets a badge I need to tell him about it. For example, when a user completes her profile, does a set number of ratings, or makes a certain number of comments a badge is rewarded. Right now the only way for the user to tell that she has a new badge is to go to the badge page, but I want to gently inform the user of the event.

Using django notifications would work, but the system we've got in place would be too jarring (currently it loads a modal) and more expensive since it hits the database.

Thanks in advance.

+2  A: 

The Django messages framework operates against HTTP requests rather than users (so it also works for anonymous users). A signal would have no idea of which request to attach a message to, and chances are the user in question probably wouldn't even be logged in at the time.

It sounds like what you're trying to do would be better suited to something like django-notification, http://github.com/jtauber/django-notification/ .

Rolo
Thanks, this is exactly what I'm looking for.
nestling
Ugh ... upon reconsideration the django notification route seems less enticing. Minimizing queries to the db is a priority.
nestling