Configurable Javascript settings in Django.
Project description
Configurable JavaScript settings in Django
==========================================
INSTALATION
===========
Add 'settingsjs' to your INSTALLED_APPS (for the templates)
Include 'settingsjs.urls' in your urls.
Add a script tag with src="{% url settings_js %}"
e.g.
<script type="text/javascript" src="{% url settings_js %}"></script>
Access the settings in JavaScript using Setting.get and Setting.get:
<script type="text/javascript">
var myapp_settings = Setting.get('myapp-settings');
Setting.set('some_key', 'some value');
</script>
Setting JavaScript settings
===========================
Use the SETTINGS_JS setting to specify settings:
e.g.
SETTINGS_JS = {
'myapp-settings': {
"fu": "bar",
}
}
Use settingsjs.signals.collect_settings:
e.g. In a file that will always be loaded (such as a models or urls file).
from settingsjs.signals import collect_settings
from django.dispatch import receiver
@receiver(collect_settings)
def videos_settingsjs(sender, jssettings=None, **kwargs):
if jssettings is not None:
jssettings['myapp-settings'] = {
"fu": "bar",
}
==========================================
INSTALATION
===========
Add 'settingsjs' to your INSTALLED_APPS (for the templates)
Include 'settingsjs.urls' in your urls.
Add a script tag with src="{% url settings_js %}"
e.g.
<script type="text/javascript" src="{% url settings_js %}"></script>
Access the settings in JavaScript using Setting.get and Setting.get:
<script type="text/javascript">
var myapp_settings = Setting.get('myapp-settings');
Setting.set('some_key', 'some value');
</script>
Setting JavaScript settings
===========================
Use the SETTINGS_JS setting to specify settings:
e.g.
SETTINGS_JS = {
'myapp-settings': {
"fu": "bar",
}
}
Use settingsjs.signals.collect_settings:
e.g. In a file that will always be loaded (such as a models or urls file).
from settingsjs.signals import collect_settings
from django.dispatch import receiver
@receiver(collect_settings)
def videos_settingsjs(sender, jssettings=None, **kwargs):
if jssettings is not None:
jssettings['myapp-settings'] = {
"fu": "bar",
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-settingsjs-0.1.5.tar.gz
.
File metadata
- Download URL: django-settingsjs-0.1.5.tar.gz
- Upload date:
- Size: 2.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 687faeff10ea8484a79eff1c097e346df23152e5ac5f322ae17771b7d0a0c5f2 |
|
MD5 | 12c49f1eb3c63dfc40dfd04541d3d575 |
|
BLAKE2b-256 | 91d8b66feff9325c5c65e3c16cdce1d58179c0dbc35ed520407366c3ccca6e57 |