This release is a pre-release and may not be stable for production use.
django_js_utils - Django JS Utils
django_js_utils is a small utility library that aims to provide JavaScript/Django developers with a few utilities that will help the development of RIA on top of a Django Backend.
Reversing Django Urls from Javascript
Why is this useful
One of the pillars of Django is DRY principle and hardcoding your urls in Javascript is violating that principle.
Moreover, building parametrized urls on the fly is error-prone and ugly.
What is included
A snippet of Javascript implementation of Django reverse function that can be found in django_js_utils.js
A view jsurls to generate a list of all of your Django urls.
Installation and usage
Add django_js_utils to your python path and add the django_js_utils application to your INSTALLED_APPS
Add the jsurls view to your URL patterns, e.g.,
(r'^jsurls.js$', 'django_js_utils.views.jsurls', {}, 'jsurls'),
Load the static django_js_utils.js (which contains the reverse function) and the dynamically-generated jsurls.js from every web page where you plan to use the reverse function (likely just your base.html template). Example:
<script type="text/javascript" src="{% staticfile 'django_js_utils.js' %}"></script>
<script type="text/javascript" src="{% url jsurls %}"></script>
In your JavaScript code, reverse URLs as follows:
django_js_utils.urls.resolve('dashboard')
django_js_utils.urls.resolve('time_edit', { project_id: 1, time_id: 2 })
For more information about usage, see example.html
TO-DO
Handle the unnamed Django urls that result in <> in urls.js file, but are not handled in Javascript resolver.
Write unit tests
Promote the code
Metadata
Release files for django-js-utils 0.0.5dev
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-js-utils-0.0.5dev.tar.gz | 3.6 kB | Without provenance | Details for django-js-utils-0.0.5dev.tar.gz |
Release files / django-js-utils-0.0.5dev.tar.gz
| Download URL | django-js-utils-0.0.5dev.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e0caf39b26519711143b14c0e94d6ee8b21c1a5a1756f33c841ce918b6a7559
|
|
BLAKE2b-256 checksum How to use checksums |
d672350e8c2c9e9f77f8a0b2bcd6c5afcf115d042c4e79295ebc7153d6e1b680
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-js-utils 0.0.5dev
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.