Django-Directmessages is a low-level and easy-to-use Django App to manage simple directmessages.
Project description
Django-Directmessages
Django-Directmessages is a low-level and easy-to-use Django App to manage simple directmessages. In contrast to other Django Apps for messaging, Django-Directmessages doesn’t use any type of pre-built templates and is concentrated on the programmatic usage.
Django-Directmessage is thought to be used with APIs or small apps, but can be used for any type of messaging. It featues:
- Sending of private 1-to-1 messages between users.
- Listing unread messages for a given user.
- Read a given message
- Get all conversation partners/contacted users for a given user
- Read a whole conversation between two users.
Requirements
Django >= 1.5 is supported
Installation
- pip install django-directmessages
- add "directmessages" to INSTALLED_APPS and run python manage.py migrate.
Usage
Import the Message Management API on top of your views.py
from directmessages.apps import Inbox
- Send message: Inbox.send_message(from_user, to_user, message)
- List all unread messages: Inbox.get_unread_messages(user)
- Read a message (and mark as read): Inbox.read_message(message)
- Print a message as <user>: <message>: Inbox.read_message_formatted(message)
- Print a list of all conversation partners for a user: Inbox.get_conversations(users)
- Get a conversation between two users: Inbox.get_conversation(user1, user2, _limit_, _reversed_, _mark_read_)
- Limit (Int: optional): Instead of getting the whole conversation, get the first 50 (depends on reversed)
- Reversed (Bool: optional): Usually the ‘limit’-param gives back the first x messages, if you put Reversed to True, limit will give back the x latest messages.
- Mark_Read (Bool: optional): Mark all messages in conversation as read
Signals
You can use the following signals to extend the app for your needs
- message_sent:
- Gets called as soon as a message is sent. Provides the Message object, the sender and the recipient as params.
- message_read:
- Gets called as soon as a message is read: Provides the Message object, the sender and the recipient as params.
Contributing
Bug reports, patches and fixes are always welcome!
To Do
- Add some security functions (e.g checking if user is allowed to read a message)
- Add some custom exceptions (e.g. when no message was found)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size django_full_directmessages-0.9.17-py2-none-any.whl (9.1 kB) | File type Wheel | Python version py2 | Upload date | Hashes View |
Filename, size django-full-directmessages-0.9.17.tar.gz (6.8 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for django_full_directmessages-0.9.17-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87b60d9b41be975ee65d096f02bc8c94a3d06e3978eb27b2b3662bbbcd141d4f |
|
MD5 | a8aa05bfaef2c8539b49f27d58d6897d |
|
BLAKE2-256 | 5781ae61b3a1914375a02f0f5f2b355607a594adb95a423213c2c14236fbb606 |
Hashes for django-full-directmessages-0.9.17.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | c364448af753c4f640af44460ec5c867fb36c66275f3c6d35334e60649b6aba1 |
|
MD5 | 03f23a612e7f6220dd996af248b7df5d |
|
BLAKE2-256 | e195b8218ff4c1b274972a03f7ac9c4472bc52ffd52548d07c49f81c5ac3f452 |