Bearle / django_private_chat2

Chat app for Django, powered by Django Channels, Websockets & Asyncio
MIT License
295 stars 80 forks source link

How to implement django_private_chat2 into my project #46

Open LieuMai opened 1 year ago

LieuMai commented 1 year ago

Description

I tried to implement this package to my project but when I go to http://127.0.0.1:8000/dialogs/ it show {"page": 1, "pages": 1, "data": []}

In my django admin page I saw the Dialogs and Messages, I add a dialogs and refresh http://127.0.0.1:8000/dialogs/ but it show {"page": 1, "pages": 1, "data": [{"id": 1, "created": 1692979771, "modified": 1692979771, "other_user_id": "2", "unread_count": 0, "username": "liaomei", "last_message": null}]}

What I Did

I followed the quick start step and add the css, js and root id div into my template

base.html

    {% block css %}{% endblock %}
    <title>dimsum - {% block title %}{% endblock title %}</title>
  </head>

  <body>
    {% include 'components/modals.html' %}
    {% include 'components/navbar.html' %}
    <div class="ui container">
      <div id="root"></div>
      {% block content %}
      {% endblock content %}
    </div>

    {% block scripts %}{% endblock scripts %}
    {% block extra_js %}{% endblock %}

settings.py

ASGI_APPLICATION = "dimsum.asgi.application"

CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("127.0.0.1", 6379)],
        },
    },
}