I am trying to use django-directmessages app. It's an application to manage simple direct messages. A part of the Documentation says:
Import the Message Management API on top of your views.py
from directmessages.apps import Inbox
Inbox.send_message(from_user, to_user, message)
Inbox.get_unread_messages(user)
Inbox.read_message(message)
Print a message as : : 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_)
How can i implement this application in my views.py file ?
In a views.py
, you could implement it like follows:
Have a form, which sends a post request with a message form field to an url like /chat/<id>/send
, with ID being the user you want to contact.
In your views.py
, do something like:
Inbox.send_message(request.user, User.objects.get(id), request.GET.get('message'))