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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-settingsjs-0.1.5.tar.gz
Algorithm Hash digest
SHA256 687faeff10ea8484a79eff1c097e346df23152e5ac5f322ae17771b7d0a0c5f2
MD5 12c49f1eb3c63dfc40dfd04541d3d575
BLAKE2b-256 91d8b66feff9325c5c65e3c16cdce1d58179c0dbc35ed520407366c3ccca6e57

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