07 February 2011

Django Offline Messages

There was a way in Django to leave a message in User.message_set, so the user will be able to see this message after login. But this storage is deprecated as of now and will be totally removed in Django 1.4. That forced me to create database storage for messages. Here it is: django-offline-messages.

To use it you have to add some options to your settings.py file:

  • Add 'offline_messages' to INSTALLED_APPS

  • Set MESSAGE_STORAGE to 'offline_messages.storage.OfflineStorageEngine'



If you want to create a message, just type:

from offline_messages.utils import create_offline_message

user = User.objects.get(username='dbudashny')
create_offline_message(user, "This is a message")

1 comment:

  1. How do you query these comments when the use next logs in, and does your system keep a complete record of all messages received?

    ReplyDelete

Total Pageviews

Followers