django-fe-manager
Manage front end dependencies in Django
Usage
Create a FE_MANAGER variable in your project settings defining the modules that can be used in your project. An example:
FE_MANAGER = {
'bootstrap': {
'version': '4.0.0',
'js': ['/static/js/bootstrap.bundle.min.js'],
'css': ['/static/css/bootstrap.css', '/static/css/custom.css'],
'dependencies': {'jquery'}
},
'jquery': {
'version': '3.2.1',
'js': ['/static/private/js/vendors/jquery-3.2.1.min.js']
},
'moment': {
'version': '2.24.0',
'js': ['https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js']
},
'chartjs': {
'version': '2.9.3',
'js': ['https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js'],
'dependencies': {'moment'}
}
}
In your base view load the module, declare your dependencies, declare a dummy block at the beggining and add the css and js output tags:
{% load fe_manager %}
{% fe_manager_add_module 'bootstrap' %}
{% fe_manager_add_module 'jquery' %}
{% block fe_manager %}{% endblock fe_manager %}
<!DOCTYPE html>
<html>
<head>
<!-- Title and other HTML code... -->
<!-- Output CSS -->
{% fe_manager_output_css %}
</head>
<body>
<!-- Content and other stuff... -->
{% block content %}{% endblock content%}
<!-- Output JS -->
{% fe_manager_output_js %}
</body>
</html>
Every child view can now add its dependencies in the following way...
{% extends 'base.html' %}
{% load fe_manager %}
{% block fe_manager %}
{% fe_manager_add_module 'chartjs' %}
{% endblock fe_manager %}
{% block content %}
Content here!
{% endblock content %}
The plugin will take care of dependency ordering and outputting both JS and CSS to your base template!
0.0.3
- Add some documentation
0.0.2
- Fix packaging (utils package not being included previously).
0.0.1
- Initial release on PyPi.
Metadata
Release files for django-fe-manager 0.0.3
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-fe-manager-0.0.3.tar.gz | 7.4 kB | Without provenance | Details for django-fe-manager-0.0.3.tar.gz |
Release files / django-fe-manager-0.0.3.tar.gz
| Download URL | django-fe-manager-0.0.3.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
759c55ede7228119b0eaf0a1f49420193927ff528e1fc5eca24319b932cc825f
|
|
BLAKE2b-256 checksum How to use checksums |
58640658670336b35fed044921928306a8d73c535c94bd5b49b243c950c8dd86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.4
|
Security for django-fe-manager 0.0.3
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.