How to create a user to user message system using Django?
Asked Answered
I

3

9

I am trying to create a private messaging system using Django. It doesn't have to be like a live chat, just have an inbox and be able to respond, simple thing like that. So far, from research I have found two things: django.contrib.messages which doesn't seem to be for private messages, but rather messages from the system to a user. Then I also found django-postman which seems to be what I'm looking for, but there seems to be little documentation on how to use it. So has anybody used anything else to accomplish this? Or am I wrong about django.contrib.messaging? Or is there good documentation on django-postman that I'm missing?

Institutionalize answered 21/9, 2015 at 4:38 Comment(1)
curious to know what you ended up using?Shows
M
25

You can create your own custom message app.

Models for Message like app : Class Message():

Class Message(models.Model):
     sender = models.ForeignKey(User, related_name="sender")
     reciever = # almost same as above field, just change the related-name
     msg_content = # text field 
     created_at = # time field

Create a form for this model, use model form .

filter "Inbox" queries in views.py by

Message.objects.filter(reciever=request.user)

filter "Sent Box" queries in views.py by

Message.objects.filter(sender = request.user)
Mclean answered 21/9, 2015 at 6:43 Comment(2)
That sounds like what I'm looking to do. I'm just not sure how to do it in django because I am really not too familiar with it. So I would create the class in models, which is understandable, but then everything else would be created in views? So far I have only created things in models and used them by modifying admin.Institutionalize
django 'views.py' takes request as argument and return 'response' (Http Response) with some data you want to render on your html template page.Mclean
E
1

There is good documentation on django-postman that you're missing:

https://bitbucket.org/psam/django-postman/wiki/browse/

or

http://django-postman.readthedocs.org/en/latest/

Effusive answered 15/10, 2015 at 7:57 Comment(0)
S
1

For queries like these, I usually head to Django Packages (https://djangopackages.org/) which lists popular Django packages with comparisons, categorised by the functionality needed.

It has a grid for messaging and based on this grid, django-messages, django-private-chat and django-postman seem to be the top ones.

Shows answered 24/4, 2018 at 10:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.