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.4.tar.gz (2.1 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-settingsjs-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a8fa7ad563c23c2ac4fb74d594d5ff1bfbeb60ea5f49d7bbcb319ef3fe328c4c
MD5 96ff070bc6ea937903acf7d4d3ceaebe
BLAKE2b-256 7a068b77291e93853b9b6aa2bb136dd6ee05e2913d71b4f60f42336bd65d0be2

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