Skip to main content

Helping you use websockets in an effective way in views

Project description

Welcome to Sockpuppet 👋

downloads License: MIT Documentation
semantic-release Tests

🎉 You just discovered an exciting new way to build modern, reactive, real-time apps with Django.

Why should I spend time exploring this? If you use current frontend libraries, such as react, vue or angular you end up creating state for the frontend and then updating state changes in the backend through an api.

This means that you forgo server-rendered html with the advantages that brings + you'll end up with a more complex app overall.

With this library you can still use normal django templates, and any frontend state you change will be directly reflected in the backend. Currently this happens through the use of websockets.

This is the django implementation of the excellent rails library stimulus-reflex, which in turn is inspired by Phoenix LiveView.

Hit me up on twitter if you have any questions. Twitter follow

📚 Documentation

⚡️ Get started

pip install django-sockpuppet

# If performance is important you can take advantage lxml parsing
# It will typically speed up the round trip by 30-90ms depending on the html
pip install django-sockpuppet[lxml]

# Add these into INSTALLED_APPS in settings.py
INSTALLED_APPS = [
    'channels',
    'sockpuppet'
]

# generates scaffolding for webpack.config.js and installs required js dependencies
# if you prefer to do that manually read the more thorough documentation
python manage.py initial_sockpuppet

# scaffolds a new reflex with everything that's needed.
python manage.py generate_reflex app_name name_of_reflex

You're almost there, read about how to tie it all together in the quickstart documentation

💙 Community

  • Discord - We share the discord together with stimulus-reflex, and there is a channel dedicated for python/django discussions.
  • django-sockpuppet-expo - Do you want more examples? There code examples of chats, book search, etc ... We accept PRs :)

🛠 Development in the repo

See some common commands that can be useful for development

pip install -r requirements_dev.txt
invoke -l

Try out a minimal example manually

git clone git@github.com:jonathan-s/django-sockpuppet.git
npm install
npm run build:test
python manage.py runserver
# visit https://localhost:8000/test

⛑ Running tests locally

The most important tests are integration tests that makes sure that frontend and backend work together in conjunction with each other.

# Install the cypress et al
npm install

# Spin up a dev server.
python manage.py runserver

# Run the cypress tests
npm run cypress:run

🔜 Release

pip install -r requirements_dev.txt
invoke release -b feature

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sockpuppet-0.5.1.tar.gz (35.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_sockpuppet-0.5.1-py2.py3-none-any.whl (40.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-sockpuppet-0.5.1.tar.gz.

File metadata

  • Download URL: django-sockpuppet-0.5.1.tar.gz
  • Upload date:
  • Size: 35.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.2

File hashes

Hashes for django-sockpuppet-0.5.1.tar.gz
Algorithm Hash digest
SHA256 3dfb072c32fcce3e313e065b6094855871dca39a76e8e1ddf95d1eb7542232c3
MD5 960e14cc3ce18b3c076ac4df56d584c4
BLAKE2b-256 5e20d5888cd6ee781b9c18392279e0abc9e2e978cf2d89431cf3aa4e14255051

See more details on using hashes here.

File details

Details for the file django_sockpuppet-0.5.1-py2.py3-none-any.whl.

File metadata

  • Download URL: django_sockpuppet-0.5.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.7.2

File hashes

Hashes for django_sockpuppet-0.5.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0bbdd1f7f403a963a6b61aee167e424d1417e49c6673b50cfb72aa2452564d78
MD5 4eaa9eac1cd715618ab9b656bc5d5ff6
BLAKE2b-256 daebfb84dee9d34c0fc911796fe55bf30975e1fd67ca6fc9b0de446f250588ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page