django-idom allows Django to integrate with IDOM

Related tags

Django python django idom
Overview

Django IDOM

Tests Version Info License: MIT

django-idom allows Django to integrate with IDOM, a package inspired by ReactJS for creating responsive web interfaces in pure Python.

You can try IDOM now in a Jupyter Notebook: Binder

Install Django IDOM

pip install django-idom

Django Integration

To integrate IDOM into your application you'll need to modify or add the following files to your_project:

your_project/
├── __init__.py
├── asgi.py
├── settings.py
├── urls.py
└── example_app/
    ├── __init__.py
    ├── idom.py
    ├── templates/
    │   └── your-template.html
    └── urls.py

asgi.py

Follow the channels installation guide in order to create ASGI websockets within Django. Then, we will add a path for IDOM's websocket consumer using IDOM_WEBSOCKET_PATH.

Note: If you wish to change the route where this websocket is served from, see the available settings.

import os

from django.core.asgi import get_asgi_application

from django_idom import IDOM_WEBSOCKET_PATH

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_app.settings")

# Fetch ASGI application before importing dependencies that require ORM models.
http_asgi_app = get_asgi_application()

from channels.routing import ProtocolTypeRouter, URLRouter

application = ProtocolTypeRouter(
    {
        "http": http_asgi_app,
        "websocket": URLRouter(
          # add a path for IDOM's websocket
          [IDOM_WEBSOCKET_PATH]
        ),
    }
)

settings.py

In your settings you'll need to add django_idom to the INSTALLED_APPS list:

INSTALLED_APPS = [
  ...,
  "django_idom",
]

You may configure additional options as well:

# the base URL for all IDOM-releated resources
IDOM_BASE_URL: str = "_idom/"

# Set cache size limit for loading JS files for IDOM.
# Only applies when not using Django's caching framework (see below).
IDOM_WEB_MODULE_LRU_CACHE_SIZE: int | None = None

# Configure a cache for loading JS files
CACHES = {
  # Configure a cache for loading JS files for IDOM
  "idom_web_modules": {"BACKEND": ...},
  # If the above cache is not configured, then we'll use the "default" instead
  "default": {"BACKEND": ...},
}

urls.py

You'll need to include IDOM's static web modules path using IDOM_WEB_MODULES_PATH. Similarly to the IDOM_WEBSOCKET_PATH. If you wish to change the route where this websocket is served from, see the available settings.

from django_idom import IDOM_WEB_MODULES_PATH

urlpatterns = [
    IDOM_WEB_MODULES_PATH,
    ...
]

example_app/components.py

This is where, by a convention similar to that of views.py, you'll define your IDOM components. Ultimately though, you should feel free to organize your component modules you wish. The components created here will ultimately be referenced by name in your-template.html. your-template.html.

import idom

@idom.component
def Hello(greeting_recipient):  # component names are camelcase by convention
    return Header(f"Hello {greeting_recipient}!")

example_app/templates/your-template.html

In your templates, you may inject a view of an IDOM component into your templated HTML by using the idom_component template tag. This tag which requires the name of a component to render (of the form module_name.ComponentName) and keyword arguments you'd like to pass it from the template.

idom_component module_name.ComponentName param_1="something" param_2="something-else"

In context this will look a bit like the following...

">

{% load static %}
{% load idom %}


<html>
  <body>
    ...
    {% idom_component "your_project.example_app.components.Hello" greeting_recipient="World" %}
  body>
html>

example_app/views.py

You can then serve your-template.html from a view just like any other.

from django.http import HttpResponse
from django.template import loader


def your_view(request):
    context = {}
    return HttpResponse(
      loader.get_template("your-template.html").render(context, request)
    )

example_app/urls.py

Include your view in the list of urlpatterns

from django.urls import path
from .views import your_view  # define this view like any other HTML template view

urlpatterns = [
    path("", your_view),
    ...
]

Developer Guide

If you plan to make code changes to this repository, you'll need to install the following dependencies first:

Once done, you should clone this repository:

git clone https://github.com/idom-team/django-idom.git
cd django-idom

Then, by running the command below you can:

  • Install an editable version of the Python code

  • Download, build, and install Javascript dependencies

pip install -e . -r requirements.txt

Finally, to verify that everything is working properly, you'll want to run the test suite.

Running The Tests

This repo uses Nox to run scripts which can be found in noxfile.py. For a full test of available scripts run nox -l. To run the full test suite simple execute:

nox -s test

To run the tests using a headless browser:

nox -s test -- --headless
Issues
  • Make django_idom an installable app

    Make django_idom an installable app

    enhancement 
    opened by rmorshea 52
  • Django IDOM

    Django IDOM

    This is the most minimalistic Django configuration possible that can support Websockets.

    I've used folder structure and file naming schemes suggested by Django documentation.

    Also included the Daphne webserver in the requirements for testing on more than just the development webserver.

    In order to get this configuration running

    1. cd <repo_root_dir>
    2. pip install requirements.txt
    3. python manage.py migrate to create the initial database
    4. python manage.py runserver to run the django development test server. Alternatively, daphne dj_idom.asgi:application to run the production-grade webserver.

    Here's the files in the repo: dj_idom/static/scripts.js: Client side websocket dj_idom/templates/base.html: HTML base template. dj_idom/consumers.py: Server side websocket dj_idom/asgi.py: Websocket URL routing dj_idom/urls.py: HTTP URL routing dj_idom/settings.py: Django boot time config manage.py: Django project management utility

    opened by Archmonger 23
  • Allow adding class to a template tag div

    Allow adding class to a template tag div

    Adds class as a template tag parameter.

    Additionally, unpinned Twisted to the latest version due to them fixing Django Channels issues. Version <21 was having install issues on Windows.

    opened by Archmonger 22
  • Fix JS Builds on Windows

    Fix JS Builds on Windows

    • Fix JS build issues causing Failed to resolve module specifier "react"
    • Look into whether channels can be monkey-patched to fix the ChannelsLiveServerTestCase

    Full error: Uncaught TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".

    bug 
    opened by Archmonger 14
  • Advanced Websocket Features

    Advanced Websocket Features

    New Features

    • [x] Automatic WS reconnection (settings.py:IDOM_WS_RECONNECT_TIMEOUT)
    • [x] Propogate WS down to components
    • [x] Support authenticated components (Login the user and save the session if auth middleware is detected)
    • [x] Pin "idom-client-react": "^0.33.3"
    • [x] Update tests to add websocket as a component parameter
    • [x] Update tests to use render shortcut instead of HttpResponse
    • [x] Change ALLOWED_HOSTS = ["*"] in tests to allow LAN access
    • [x] Rename IdomAsyncWebSocketConsumer -> IdomAsyncWebsocketConsumer
    • [x] Readme clean up. fixes, and updates
    documentation enhancement 
    opened by Archmonger 13
  • Auto populate IDOM component registry

    Auto populate IDOM component registry

    When Django first loads, attempt to populate the IDOM component registry.

    This design was inspired by django_compressor. See https://github.com/idom-team/django-idom/discussions/20 for more details.

    enhancement low priority 
    opened by Archmonger 6
  • Create Django templatetags

    Create Django templatetags

    Barebones structure to allow for a user to simply type

    {% load idom %}
    <head>
       {% idom_scripts %}
    </head>
    
    <body>
       {% idom_view 'root' %}
    </body>
    

    to import IDOM into Django.

    note: these template tags are only registered if the user adds "django_idom" to settings.py:INSTALLED_APPS

    As I mentioned, there is gonna be some slight awkwardness to this due to build.js not being built directly to django_idom/static/js/idom.js. However, that can be resolved via modifying our deployment procedure.

    I've included some HTML and JS comments just for our sake. We'll remove them before we merge this PR.

    Alternatively, we can have idom.js point to JavaScript stored on a CDN somewhere rather than locally deploying. But, many Django users due prefer local files due to things such as Django-Compressor and Django-Pipelines though.

    opened by Archmonger 5
  • synchronize JS and Py version requirements for IDOM

    synchronize JS and Py version requirements for IDOM

    The IDOM client and core libraries now have synchronized versions. To ensure they work correctly together we need to ensure the version requirements we use both are the same.

    opened by rmorshea 5
  • Avoid multiple component registrations

    Avoid multiple component registrations

    Since one can use the same component more than once we should avoid calling _register_component more than once if it's already been done. A simple containment check in IDOM_REGISTERED_COMPONENTS should work here.

    opened by rmorshea 2
  • Can not resolve

    Can not resolve "react" when manually building on Windows

    Old Behavior

    When executing the standard build procedure, the following error is given in console

    Uncaught TypeError: Failed to resolve module specifier "react". Relative references must start with either "/", "./", or "../".

    New Behavior

    Unbork django-idom builds that are created on Windows machines.

    Implementation Details

    No response

    Code of Conduct

    bug triage 
    opened by Archmonger 0
  • Component Initial HTML

    Component Initial HTML

    The idea of this PR is to allow for customizable initial HTML.

    This is useful for...

    • Showing a simple loader/message in situations where a websocket connection could not be formed (Message display can be delayed via CSS).
    • Can be used to run simple scripts on the component div.

    This is different than an IDOM Core idom.component fallback=... that we have discussed due to the fact that this implementation fallback has no WS reliance.

    enhancement 
    opened by Archmonger 1
  • Add VS Code Configuration

    Add VS Code Configuration

    Configuration file should be set up to automatically enable some settings, such as EOF newlines and formatting on save.

    Additionally, we should add a list of suggested extensions to improve development workflow.

    opened by Archmonger 0
  • Threaded dispatcher loop

    Threaded dispatcher loop

    This PR attempts runs the dispatcher in a thread.

    Merging this pull request will significantly increase scalability. For example, would allow servicing requests in scenarios where there's hundreds of clients connected to a single webserver.

    Details

    • Run the renderer within a single self._idom_dispatcher_thread
    • Kill off render threads upon websocket disconnection.
    • Replace asyncio.Queue with a thread-safe async queue janus.Queue().async_q
    • Remove useless super() in disconnect()
    enhancement 
    opened by Archmonger 20
  • Websocket Consumer can get stuck in infinite connection loop

    Websocket Consumer can get stuck in infinite connection loop

    Old Behavior

    WebSocket HANDSHAKING /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61944]
    WebSocket CONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61944]
    WebSocket DISCONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61944]
    WebSocket HANDSHAKING /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61945]
    WebSocket CONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61945]
    WebSocket DISCONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61945]
    WebSocket HANDSHAKING /_idom/websocket/test_app.components.SimpleBarChart/ [127.0.0.1:61953]
    WebSocket CONNECT /_idom/websocket/test_app.components.SimpleBarChart/ [127.0.0.1:61953]
    WebSocket DISCONNECT /_idom/websocket/test_app.components.SimpleBarChart/ [127.0.0.1:61953]
    WebSocket HANDSHAKING /_idom/websocket/test_app.components.Button/ [127.0.0.1:61955]
    WebSocket CONNECT /_idom/websocket/test_app.components.Button/ [127.0.0.1:61955]
    WebSocket DISCONNECT /_idom/websocket/test_app.components.Button/ [127.0.0.1:61955]
    WebSocket HANDSHAKING /_idom/websocket/test_app.components.HelloWorld/ [127.0.0.1:61956]
    WebSocket CONNECT /_idom/websocket/test_app.components.HelloWorld/ [127.0.0.1:61956]
    WebSocket DISCONNECT /_idom/websocket/test_app.components.HelloWorld/ [127.0.0.1:61956]
    WebSocket HANDSHAKING /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61957]
    WebSocket CONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61957]
    WebSocket DISCONNECT /_idom/websocket/test_app.components.ParametrizedComponent/ [127.0.0.1:61957]
    HTTP GET /_idom/web_module/from-template/victory-bar.js 200 [0.01, 127.0.0.1:64500]
    

    I'm really not sure how to trigger this. Seems to happen sometimes while using the development webserver with autoreload (settings.py:DEBUG=True)

    When this occurs, the websocket will be stuck in a perpetual handshake/connect loop for a minute or two. Happens the same within Conreq, and I'm not using any external web modules over there yet.

    Somehow, using a keyboard interrupt (CTRL+C) to attempt to escape the situation does not resolve the bug. Will still be stuck in this infinite connection loop upon restarting the development webserver (manage.py runserver)

    New Behavior

    WS connection and render should be performed smoothly

    Implementation Details

    Need to debug

    Code of Conduct

    bug high priority 
    opened by Archmonger 7
  • WS connection close can cause Render exception

    WS connection close can cause Render exception

    Old Behavior

    If the webpage is closed or refreshed prior to component load, an exception will occur.

    2021-10-16T22:57:18-0700 | ERROR | Failed to render Button(2992041646976, websocket=WebsocketConnection(scope={'type': 'websocket', 'path': '/_idom/websocket/test_app.components.Button/', 'raw_path': b'/_idom/websocket/test_app.components.Button/', 'headers': [(b'host', b'127.0.0.1:8000'), (b'connection', b'Upgrade'), (b'pragma', b'no-cache'), (b'cache-control', b'no-cache'), (b'upgrade', b'websocket'), (b'origin', b'http://127.0.0.1:8000'), (b'sec-websocket-version', b'13'), (b'user-agent', b'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like 
    Gecko) Chrome/94.0.4606.81 Safari/537.36'), (b'accept-encoding', b'gzip, deflate, br'), (b'accept-language', b'en'), (b'cookie', b'csrftoken=jzHH9Te6cml6zXxOwjSkdsMupUjoIPPLGkNGMvCsyUsdidzNmYJNBFWeflJI59Qe; sessionid=1t95jxh44o9a1zfzcgsamlhau1mxjilj'), (b'sec-gpc', b'1'), (b'sec-websocket-key', b'd5LydM5OiDLcAgSqam7GcQ=='), (b'sec-websocket-extensions', b'permessage-deflate; client_max_window_bits')], 'query_string': b'kwargs=%7B%7D', 'client': ['127.0.0.1', 52403], 'server': ['127.0.0.1', 8000], 'subprotocols': [], 'asgi': {'version': '3.0'}, 'cookies': {'csrftoken': 'jzHH9Te6cml6zXxOwjSkdsMupUjoIPPLGkNGMvCsyUsdidzNmYJNBFWeflJI59Qe', 'sessionid': '1t95jxh44o9a1zfzcgsamlhau1mxjilj'}, 'session': <django.utils.functional.LazyObject object at 0x000002B8A39433A0>, 'user': <channels.auth.UserLazyObject object at 0x000002B8A3943CA0>, 'path_remaining': '', 'url_route': {'args': (), 'kwargs': {'view_id': 'test_app.components.Button'}}}, close=<bound method AsyncWebsocketConsumer.close of <django_idom.websocket_consumer.IdomAsyncWebsocketConsumer object at 0x000002B8A3943E50>>, disconnect=<bound method IdomAsyncWebsocketConsumer.disconnect of <django_idom.websocket_consumer.IdomAsyncWebsocketConsumer object at 0x000002B8A3943E50>>, view_id='test_app.components.Button'))
    Traceback (most recent call last):
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 207, in _render_component
        self._render_model(old_state, new_state, raw_model)
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 245, in _render_model
        self._render_model_children(old_state, new_state, raw_model.get("children", []))
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 364, in _render_model_children
        self._render_model(old_child_state, new_child_state, child)
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 244, in _render_model
        self._render_model_attributes(old_state, new_state, raw_model)
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 266, in _render_model_attributes
        self._render_model_event_handlers_without_old_state(
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\idom\core\layout.py", line 306, in _render_model_event_handlers_without_old_state
        self._event_handlers[target] = handler
    AttributeError: _event_handlers
    

    New Behavior

    Need to gracefully handle WS close within _render_model

    Implementation Details

    No response

    Code of Conduct

    triage 
    opened by Archmonger 0
  • Django Channels tests broken on Windows

    Django Channels tests broken on Windows

    Old Behavior

    ======================================================================
    ERROR: test_component_from_web_module (test_app.tests.TestIdomCapabilities)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
        self._pre_setup()
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
        self._server_process.start()
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
        self._popen = self._Popen(self)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
        return Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
        reduction.dump(process_obj, to_child)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
        ForkingPickler(file, protocol).dump(obj)
    AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    
    
    ======================================================================
    ERROR: test_counter (test_app.tests.TestIdomCapabilities)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
        self._pre_setup()
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
        self._server_process.start()
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
        self._popen = self._Popen(self)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
        return Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
        reduction.dump(process_obj, to_child)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
        ForkingPickler(file, protocol).dump(obj)
    AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    
    
    ======================================================================
    ERROR: test_hello_world (test_app.tests.TestIdomCapabilities)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
        self._pre_setup()
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
        self._server_process.start()
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
        self._popen = self._Popen(self)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
        return Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
        reduction.dump(process_obj, to_child)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
        ForkingPickler(file, protocol).dump(obj)
    AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    
    
    ======================================================================
    ERROR: test_parametrized_component (test_app.tests.TestIdomCapabilities)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\django\test\testcases.py", line 272, in _setup_and_call
        self._pre_setup()
      File "C:\Users\username\Documents\Repositories\django-idom\.venv\lib\site-packages\channels\testing\live.py", line 52, in _pre_setup
        self._server_process.start()
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\process.py", line 121, in start
        self._popen = self._Popen(self)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 224, in _Popen
        return _default_context.get_context().Process._Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\context.py", line 327, in _Popen
        return Popen(process_obj)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\popen_spawn_win32.py", line 93, in __init__
        reduction.dump(process_obj, to_child)
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 60, in dump
        ForkingPickler(file, protocol).dump(obj)
    AttributeError: Can't pickle local object 'convert_exception_to_response.<locals>.inner'    
    
    ----------------------------------------------------------------------
    Ran 0 tests in 0.027s
    
    FAILED (errors=4)
    Destroying test database for alias 'default'...
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 109, in spawn_main
    Traceback (most recent call last):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
        fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
      File "<string>", line 1, in <module>
    OSError: [Errno 9] Bad file descriptor
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 109, in spawn_main
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 109, in spawn_main
        fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
    OSError: [Errno 9] Bad file descriptor
        fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY)
    OSError: [Errno 9] Bad file descriptor
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\spawn.py", line 107, in spawn_main
        new_handle = reduction.duplicate(pipe_handle,
      File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\multiprocessing\reduction.py", line 79, in duplicate
        return _winapi.DuplicateHandle(
    OSError: [WinError 6] The handle is invalid
    

    New Behavior

    Tests should properly execute without pickling errors on Windows.

    Implementation Details

    Should be resolved within django-channels.

    Issue is being tracked on django/channels#1207

    Tested versions:

    Django == 3.2.4 - 3.2.7
    Channels == 3.0.0 - 3.0.4
    asgiref == 3.3.0 - 3.4.1
    idom == any
    django-idom == any
    

    Code of Conduct

    bug future low priority 
    opened by Archmonger 0
  • Improve performance for accessing files from IDOM_WEB_MODULES_DIR

    Improve performance for accessing files from IDOM_WEB_MODULES_DIR

    IDOM_WEB_MODULES_DIR contains JS modules that are dynamically added at runtime. Since JS files are typically loaded statically, it would be nice if we could improve how quickly these files can be accessed. There are three ways to do that:

    1. Implement a management command for collecting these static files ahead of time.
    2. Make the view accessing the files async to avoid blocking while waiting on the file system
    3. Cache this view using Django's cache framework.

    Notes

    To implement the management command we could trace over all the templates and look for idom_component template tag nodes in order to figure out what modules to import so that we can trigger the collection of the JS files into IDOM_WEB_MODULES_DIR. Then once they've been collected those files can be copied into a permanent static location.

    To do this we can take inspiration from the django compressor library which takes a similar approach. See the COMPRESS_OFFLINE setting to figure out how they're doing it. Also the compressor.offiline module contains uniform interfaces for parsing template syntax for Django and Jinja that we might want to copy (with the latest LICENSE, what to do about AUTHORS file?).


    Conversation originated from: this comment

    future 
    opened by rmorshea 8
Releases(0.0.1)
  • 0.0.1(Aug 19, 2021)

    Initial release of django-idom

    django-idom allows Django to integrate with IDOM, a package inspired by ReactJS for creating responsive web interfaces in pure Python.

    The initial release contains all the basic features requires to install IDOM into existing Django applications using the INSTALLED_APPS list and some other basic configurations that are describe in more detail within the README.

    Source code(tar.gz)
    Source code(zip)
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.4k Nov 22, 2021
pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-dev 960 Nov 25, 2021
Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

Django-Audiofield Description: Django Audio Management Tools Maintainer: Areski Contributors: list of contributors Django-Audiofield is a simple app t

Areski Belaid 160 Oct 31, 2021
A Django app that allows visitors to interact with your site as a guest user without requiring registration.

django-guest-user A Django app that allows visitors to interact with your site as a guest user without requiring registration. Largely inspired by dja

Julian Wachholz 9 Nov 23, 2021
A Django web application that allows you to be in the loop about everything happening in your neighborhood.

A Django web application that allows you to be in the loop about everything happening in your neighborhood. From contact information of different handyman to meeting announcements or even alerts.

Kennedy Ngugi Mwaura 2 Nov 7, 2021
Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project

Django URL Shortener Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project Install this package to your Dja

Rishav Sinha 4 Nov 18, 2021
Stream Framework is a Python library, which allows you to build news feed, activity streams and notification systems using Cassandra and/or Redis. The authors of Stream-Framework also provide a cloud service for feed technology:

Stream Framework Activity Streams & Newsfeeds Stream Framework is a Python library which allows you to build activity streams & newsfeeds using Cassan

Thierry Schellenbach 4.6k Nov 24, 2021
A web app which allows user to query the weather info of any place in the world

weather-app This is a web app which allows user to get the weather info of any place in the world as soon as possible. It makes use of OpenWeatherMap

Oladipo Adesiyan 3 Sep 20, 2021
Meta package to combine turbo-django and stimulus-django

Hotwire + Django This repository aims to help you integrate Hotwire with Django ?? Inspiration might be taken from @hotwired/hotwire-rails. We are sti

Hotwire for Django 31 Aug 14, 2021
django-reversion is an extension to the Django web framework that provides version control for model instances.

django-reversion django-reversion is an extension to the Django web framework that provides version control for model instances. Requirements Python 3

Dave Hall 2.7k Nov 20, 2021
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 865 Nov 17, 2021
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Feldroy 8.8k Dec 2, 2021
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App ?? We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 65 Nov 18, 2021
django-quill-editor makes Quill.js easy to use on Django Forms and admin sites

django-quill-editor django-quill-editor makes Quill.js easy to use on Django Forms and admin sites No configuration required for static files! The ent

lhy 97 Nov 12, 2021
A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, celery and redis.

Django Channels Websocket Chatbot A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, c

Yunbo Shi 5 Jun 2, 2021
A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.

Django Sage Painless The django-sage-painless is a valuable package based on Django Web Framework & Django Rest Framework for high-level and rapid web

sageteam 45 Nov 14, 2021
A beginner django project and also my first Django project which involves shortening of a longer URL into a short one using a unique id.

Django-URL-Shortener A beginner django project and also my first Django project which involves shortening of a longer URL into a short one using a uni

Rohini Rao 3 Aug 8, 2021
Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot. A fully Django starter project.

Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot ?? Features A Django stater project with fully basic requirements for a production-ready

null 5 Nov 29, 2021
APIs for a Chat app. Written with Django Rest framework and Django channels.

ChatAPI APIs for a Chat app. Written with Django Rest framework and Django channels. The documentation for the http end points can be found here This

Victor Aderibigbe 6 Nov 7, 2021