Skip to main content

Django client-side dependencies app

PyPI Version Tests

Manage client-side JS / CSS dependencies for your django project.

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
  1. Add client_side to INSTALLED_APPS

    INSTALLED_APPS = [
        ...
        'client_side',
    ]
    
  2. define client-side dependency set (see tests.dependencies for example)

  3. in settings.py, configure CLIENT_SIDE_DEPENDENCIES setting:

    CLIENT_SIDE_DEPENDENCIES = 'myproject.client_side.dependencies.DEPENDENCIES'  # dotted-path to your dependency sets
    

    (may be a dotted-path to a DependencySets object or specify the DependencySets object directly in settings.)

  4. Use {% stylesheet <name> %} and {% javascript <name> %} in your templates to pull in sets of dependencies

  5. 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

Build / Deploy Automation

Metadata

Release files for django-client-side 0.3.1

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-client-side 0.3.1
File Size Uploaded Provenance
django-client-side-0.3.1.tar.gz 7.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-client-side 0.3.1
File Interpreter ABI Platform
django_client_side-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / django-client-side-0.3.1.tar.gz

Download URL django-client-side-0.3.1.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
fc40876799592a6d7068c765328faf558271e253242f7d96902bf886c2c5475a
BLAKE2b-256 checksum
How to use checksums
212f5aa09067f9ff9bbbeb69c834ed27e47a70217298e0ee33f427d8647ceb2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / django_client_side-0.3.1-py3-none-any.whl

Download URL django_client_side-0.3.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0508a69b092a14603fc1efff1e5cfe3933e2fc39a17fc87253aec1174a82263e
BLAKE2b-256 checksum
How to use checksums
a825cde21ca8aa41ac51e47c8f1896705e33c0c98fdc552d41de38d665a5a095
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for django-client-side 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files No provenance

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