英文:
Django building a user-to-user messaging system
问题
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 !
英文:
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 !
答案1
得分: 2
如果您想要一个快速且简单的解决方案,我可以建议:
创建一个Conversation模型,其中包含参与者和消息,使用m2m字段。
创建一个Message模型,其中包含发送者、接收者和消息内容以及其他元数据(发送日期、阅读日期等)。
然后,您应该为消息创建一个保存方法,该方法将根据发送者和参与者创建一个Conversation对象。
其余部分是创建一些查询集,用于过滤消息和对话。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论