Simple client-side dependency management for your django project.
Project description
Django client-side dependencies app
Manage client-side JS / CSS dependencies for your django project.
- Version: 0.3.1
- Author: powderflask
- Source: https://github.com/powderflask/django-client-side
- MIT License
OVERVIEW:
- Maintain client-side dependencies in one place (i.e., not scattered in templates).
- Provides testable, executable client-side app dependencies set.
- Template tags used to pull JS / CSS dependencies into templates.
- Local static resources and/or from CDN.
- Use any client-side build tools or none - demo app uses npm as JS package manager and build tool.
- conditional dependencies for different build environments
Dependencies:
- python 3
- django
Quick start
pip install https://github.com/powderflask/django-client-side.git
-
Add
client_sidetoINSTALLED_APPSINSTALLED_APPS = [ ... 'client_side', ] -
define client-side dependency set (see tests.dependencies for example)
-
in settings.py, configure
CLIENT_SIDE_DEPENDENCIESsetting:CLIENT_SIDE_DEPENDENCIES = 'myproject.client_side.dependencies.DEPENDENCIES' # dotted-path to your dependency sets(may be a dotted-path to a
DependencySetsobject or specify theDependencySetsobject directly in settings.) -
Use
{% stylesheet <name> %}and{% javascript <name> %}in your templates to pull in sets of dependencies -
Update your client-side dependency sets any time without ever touching your templates!
Guide
Define Client-Side Components
from client_side.component import Component, DependencySets, Script, Stylesheet
Define a Component for each dependency, with zero or more Script elemenets and/or zero or more Stylesheet elements:
component = Component(
Script(url="https://example.com/component.js", sri="sha384-js-sri-here"),
Stylesheet(url="https://example.com/component.css", sri="sha384-css-sri-here"),
)
Swap components for different environments, pass static=True for dependencies loaded from static files:
lib_common = Component(
Script(url="lib/common.js" if settings.DEBUG else "lib/common.min.js", static=True),
Stylesheet(
url="lib/common.css" if settings.DEBUG else "lib/common.min.css", static=True
),
)
Group Components into Logical Dependency Sets
Define one or more DependencySets with logical component groups:
DEPENDENCIES = DependencySets(
core=(component, lib_common,),
debug=(debug_toolbar, hijack),
)
Include DependencySets in Templates
{% load dependency_tags %}
...
{% stylesheet 'core' %}
...
{% javascript 'core' %}
{% if debug %}
{% javascript 'debug' %}
{% endif %}
Acknowledgments
Special thanks to BC Hydro, Chartwell, and all Contributors
For Developers
> pip install -r reqirements_dev.txt
Tests
> pytest> tox
Code Style
> isort> black> flake8
Versioning
- Semantic Versioning
> bumpver
Build / Deploy Automation
- invoke
> invoke -l
- GitHub Actions (see .github/workflows)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django-client-side-0.3.1.tar.gz.
File metadata
- Download URL: django-client-side-0.3.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc40876799592a6d7068c765328faf558271e253242f7d96902bf886c2c5475a
|
|
| MD5 |
1bb9a2c33e0d5080c27266a9b444f3a4
|
|
| BLAKE2b-256 |
212f5aa09067f9ff9bbbeb69c834ed27e47a70217298e0ee33f427d8647ceb2b
|
File details
Details for the file django_client_side-0.3.1-py3-none-any.whl.
File metadata
- Download URL: django_client_side-0.3.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0508a69b092a14603fc1efff1e5cfe3933e2fc39a17fc87253aec1174a82263e
|
|
| MD5 |
58669ee160f71736bd7d249ef7ebe1ae
|
|
| BLAKE2b-256 |
a825cde21ca8aa41ac51e47c8f1896705e33c0c98fdc552d41de38d665a5a095
|