Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 769893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:24:38+00:00 2026-05-14T18:24:38+00:00

I’m building a simple live chat into a web application running on Django, but

  • 0

I’m building a simple live chat into a web application running on Django, but one thing I’m confused about is how I should store the messages between users.

The chat will support multiple users, and a chat “session” is composed of users connected to one user that is the “host.” The application is a sort of online document collaboration thing, so user X has a document, and users Y and Z would connect to user X to talk about the document, and that would be one chat session.

If user Y disconnected for five minutes, and then signed back in and reconnected to user X, he should not get any of the messages shared between users X and Z while he was away.

if users X, Y, and Z can have a chat session about user X’s document, then users X and Y can connect to a simultaneous, but separate discussion about user Z’s document.

How should I handle this? Should I keep each message in the database? Each message would have an owner user and a target user (the host), and a separate table would be used to connect users with messages (which messages are visible to what users).

Or should I store each session as an HTML file on the server, which messages get appended to?

The problem is, I can’t just send messages directly between clients. They have to be sent to the server in a POST request, and then each client has to periodically check for the messages in a GET request. Except I can’t just have each message cleared after a client fetches it, because there could be multiple clients. How should I set this up? Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:24:39+00:00Added an answer on May 14, 2026 at 6:24 pm

    Give each message a timestamp (or just an incrementing ID). Then when the client pools, you send him all the messages that belong to the current chat, that happened in the last 10 seconds, along with their timestamps. The client can then filter out messages he’s already got. It pools every 5 seconds or so. If you don’t need the messages for logging etc, you can delete messages older than 10 seconds.

    Note that if you want to implement a chat that would really feel fast and responsive, you should consider using Reverse Ajax. In that case, the answer would be different. The server should have a list of clients registered to each chat (clients that have an HttpRequest pending). The server then sends each of them every message that is posted.

    And don’t forget to search before you reinvent the wheel. One of django’s best features is its pluggable apps archtecture.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.