Skip to main content

django-chit-chat CKC

chat for projects we help maintain @ ckc

installing

pip install django-chit-chat
# settings.py
INSTALLED_APPS = (
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.staticfiles",

    # ... add chit_chat
    "chit_chat",
)
# routing.py
from channels.auth import AuthMiddlewareStack
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter

import chit_chat.routing


application = ProtocolTypeRouter({
    'http': get_asgi_application(),
    'websocket': AuthMiddlewareStack(
        URLRouter(
            chit_chat.routing.websocket_urlpatterns
        )
    ),
})
# urls.py
from rest_framework import routers

from chit_chat.viewsets import RoomViewSet


router = routers.SimpleRouter()
router.register('chatrooms', RoomViewSet)

urlpatterns = router.urls
<!-- chat.html -->

<script>
    // Open a connection to django-chit-chat
    YourWebsocketThing.open(`wss://${window.location.host}/ws/chatroom/`)
    
    // Write messages to screen as they're sent/received
    YourWebsocketThing.onmessage(msg => writeMessageToScreen(JSON.parse(msg.data)))
    
    // You can do a GET to "/api/chatrooms/" for a list of chatrooms + messages
    $.get("/api/chat/rooms").success(d => ...)
    
    // Send a message
    function send_message(text) {
        WSClient.send(JSON.stringify({
            message_type: "chat",
            room: 1, // ID of chat room
            text: text
        }))
    }
</script>

tests

$ docker build -t django-chit-chat . && docker run django-chit-chat pytest

Releasing

  1. Update version number in setup.cfg.
  2. Create release using Github's UI.
    • Click the Choose a tag dropdown and create a new tag with the new version number.
    • Click the Generate release notes button to automatically create release notes.
    • This will trigger an action to build and push the release to PyPi.

Metadata

Release files for django-chit-chat 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-chit-chat 0.0.10
File Size Uploaded
django-chit-chat-0.0.10.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-chit-chat 0.0.10
File Interpreter ABI Platform
django_chit_chat-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 34.3 kB

Release files / django-chit-chat-0.0.10.tar.gz

Download URL django-chit-chat-0.0.10.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7edc26870d0d2ad279fd1730d938b682fce1586490fee7fb354598214128a843
BLAKE2b-256 checksum
How to use checksums
118a6158cbfe6c3c3cdffca0fcfbe5356a1ac48a5bfb3d83cd444bc10c3c85da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / django_chit_chat-0.0.10-py3-none-any.whl

Download URL django_chit_chat-0.0.10-py3-none-any.whl
Size 19.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8323fab8dc2fab36ea6ad2ca7130b2b395d145c505f9906f852d3cbc54388a47
BLAKE2b-256 checksum
How to use checksums
2aa392ac5f7ac22f41792c60fcec2b4c5925c85acccd721fc11a3372df16a621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

1 release file

0.0.1

1 release file

0.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page