Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ jobs:
run: pip install -r requirements/test-run.txt
- name: Run Tests
run: |
npm install -g npm@v7.13.0
npm install -g npm@latest
npm --version
nox -s test
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
# Django IDOM

Support for IDOM in Django
<a href="https://github.com/idom-team/django-idom/actions?query=workflow%3ATest">
<img alt="Tests" src="https://github.com/idom-team/django-idom/workflows/Test/badge.svg?event=push" />
</a>
<a href="https://pypi.python.org/pypi/django-idom">
<img alt="Version Info" src="https://img.shields.io/pypi/v/idom.svg"/>
</a>
<a href="https://github.com/idom-team/django-idom/blob/main/LICENSE">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-purple.svg">
</a>

A package for building highly interactive user interfaces in pure Python inspired by
[ReactJS](https://reactjs.org/).

**Be sure to [read the IDOM Documentation](https://idom-docs.herokuapp.com)!**

If you have ideas or find a bug, be sure to post an
[issue](https://github.com/idom-team/django-idom/issues)
or create a
[pull request](https://github.com/idom-team/django-idom/pulls). Thanks in advance!

<h3>
<a
target="_blank"
href="https://mybinder.org/v2/gh/idom-team/idom-jupyter/main?filepath=notebooks%2Fintroduction.ipynb"
>
Try it Now
<img alt="Binder" valign="bottom" height="25px"
src="https://mybinder.org/badge_logo.svg"
/>
</a>
</h3>

Click the badge above to get started! It will take you to a [Jupyter Notebooks](https://jupyter.org/)
hosted by [Binder](https://mybinder.org/) with some great examples.

### Or Install it Now

```bash
pip install django-idom
```

# Django Integration

This version of IDOM can be directly integrated into Django. For example

```python
# Example code goes here
```

For examples on how to use IDOM, [read the IDOM Documentation](https://idom-docs.herokuapp.com).
4 changes: 1 addition & 3 deletions src/django_idom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
__version__ = "0.0.1"

from .websocket_consumer import IdomAsyncWebSocketConsumer


__version__ = "0.0.1"
__all__ = ["IdomAsyncWebSocketConsumer"]
5 changes: 3 additions & 2 deletions tests/test_app/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@

from .views import Root

from django_idom import IdomAsyncWebSocketConsumer # noqa: E402


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
from channels.routing import ProtocolTypeRouter, URLRouter # noqa: E402

from django_idom import IdomAsyncWebSocketConsumer


application = ProtocolTypeRouter(
Expand Down
31 changes: 5 additions & 26 deletions tests/test_app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
import sys
from pathlib import Path


# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

SRC_DIR = BASE_DIR.parent / "src"

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
Expand All @@ -25,12 +26,9 @@

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
Expand All @@ -41,7 +39,6 @@
"channels", # Websocket library
"test_app", # This test application
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
Expand All @@ -51,9 +48,7 @@
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = "test_app.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
Expand All @@ -69,13 +64,11 @@
},
},
]

ASGI_APPLICATION = "test_app.asgi.application"

sys.path.append(str(SRC_DIR))

# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
Expand All @@ -86,10 +79,8 @@
},
}


# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
Expand All @@ -105,38 +96,26 @@
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "UTC"

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = "/static/"

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

STATIC_ROOT = os.path.join(BASE_DIR, "static-deploy")

# Static Files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = "/static/"
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "test_app", "static"),
]

STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
Expand Down