0

I'm trying to build a messaging system for my website using Django but I don't know how to do. What I want is a system that enables a user to send a message to another user, with an inbox to see the received messages and notifications that warn the user he received messages. Since it's a feature many websites need, I guess there already exists some build-in functions and templates to do that in Django. I made some researchs and I found existing apps like django-messages or django-postman but there are little or no documentations about these apps, the ways to use it in the view, the way to customize the message model or the templates, ... . I guess these apps are not widely used since there are no tutorials about them or precise documentation, but I didn't found other apps for messaging.

To summarize my question, what is the easiest way to build a customizable messaging system in Django ? If it's an app, where can I find good and easy documentation/tutorial about it ?

Thanks in advance !

Julien Mertz
  • 465
  • 2
  • 8
  • 22
  • 1
    i use https://github.com/arneb/django-messages, is not hard, just have to make your own templates and us their urls and functions. look at their code. Wen i have time i try to write some examples. – Zartch Jan 03 '20 at 16:22
  • Thank you for your answer, so basically you learnt django-messages by looking into their code ? I will try to do that then – Julien Mertz Jan 03 '20 at 18:43

1 Answers1

2

If you want a quick & simple solution I can suggest:

Create a Conversation model which will hold participants and messages using m2m fields. Create a Message model which will hold sender, recipient and message content and other metadata (send date, read date etc.)

Then you should create a save method for message which will create a Conversation object according to sender and participant.

The rest is creation of some querysets which will filter out messages and conversations.

suayip uzulmez
  • 628
  • 8
  • 23
  • Thank you for your answer, I was thinking about something like that but the problem is I would like the users to get notifications of the messages and I don't know how do something like this with Django – Julien Mertz Jan 03 '20 at 18:42
  • 1
    Well you have 'sent at and read at' metadata on your message model. Using these you can actually find out if there is unread messages or new messages. For real time notifications I suggest you check out django-notifications. – suayip uzulmez Jan 04 '20 at 19:27