Skip to main content

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",
}

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

django-settingsjs-0.1.2.tar.gz (2.0 kB view details)

Uploaded Source

File details

Details for the file django-settingsjs-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django-settingsjs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 47d6ec8e390f415f3a58b1b03b38f77dc8157f4850b1ea640a2ca26e1ae73c52
MD5 f0ac8beade65ee090c74686e47aab7ae
BLAKE2b-256 148239609bc100fe345d05cef1ca8981ba42d729b885d3528086a95ffa3e47d4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page