python-django-js-asset
Port variant v11
Summary Django forms.Media script tag (3.11)
Package version 2.2.0
Homepage https://github.com/matthiask/django-js-asset/
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v12
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 13 DEC 2023, 17:13:42 UTC
Port created 02 FEB 2018, 15:29:04 UTC
Subpackage Descriptions
single =============================================================================== django-js-asset -- script tag with additional attributes for django.forms.Media =============================================================================== Usage ===== Use this to insert a script tag via ``forms.Media`` containing additional attributes (such as id and ``data-*`` for CSP-compatible data injection.): .. code-block:: python from js_asset import JS forms.Media(js=[ JS("asset.js", { "id": "asset-script", "data-answer": "42", }), ]) The rendered media tag (via ``{{ media.js }} or {{ media }}`` will now contain a script tag as follows, without line breaks: .. code-block:: html The attributes are automatically escaped. The data attributes may now be accessed inside ``asset.js``: .. code-block:: javascript var answer = document.querySelector("#asset-script").dataset.answer; Also, because the implementation of static differs between supported Django versions (older do not take the presence of ``django.contrib.staticfiles in INSTALLED_APPS`` into account), a ``js_asset.static`` function is provided which does the right thing automatically. When adding external script assets, you should pass ``static=False to the JS object to avoid passing the script URL through static()``. In this case, you probably want to add defer or async, and maybe also integrity and crossorigin attributes. Please note that boolean attributes are not properly supported when using Django before 4.1 so specify them as follows: .. code-block:: python JS( "https://cdn.example.com/script.js", {"defer": "defer"}, static=False, ) Compatibility ============= At the time of writing this app is compatible with Django 1.8 and better (up to and including the Django master branch), but have a look at the [tox configuration ] for definitive answers.
Configuration Switches (platform-specific settings discarded)
PY311 ON Build using Python 3.11 PY312 OFF Build using Python 3.12
Package Dependencies by Type
Build (only) python-pip:single:v11
autoselect-python:single:standard
Build and Runtime python311:single:standard
Runtime (only) python-Django:single:v11
Download groups
main mirror://PYPIWHL/dc/4d/5bb8c351f2515a616576a4218c736af081edf0dd4d1eead1c7e880f74c0e
Distribution File Information
7ef3e858e13d06f10799b56eea62b1e76706f42cf4e709be4e13356bc0ae30d8 4704 django_js_asset-2.2.0-py3-none-any.whl
Ports that require python-django-js-asset:v11
python-django-mptt:v11 Django Modified Preorder Tree Traversal (3.11)