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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-settingsjs-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e182e9c69d129a8c6acffe1a91c8098166166bb6c8de0f249b5af030615dd97b
MD5 5d2573f9dbd914eeaf90f94684ed5c65
BLAKE2b-256 f5dadae6c180d135cf148f52a18dedf556aa4fb948e8a5b628acb09f985d9d39

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