Skip to content

Instantly share code, notes, and snippets.

@rromanchuk
Created April 26, 2012 09:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rromanchuk/2498121 to your computer and use it in GitHub Desktop.
Accessing setting constants in django, non idiotic way.
from django import template
from django.conf import settings
register = template.Library()
@register.simple_tag
def settings_value(name):
try:
test = settings.__getattr__(name)
return test
except AttributeError:
return ""
# ----------------------------------------------------
{% settings_value "MY_SETTINGS_VALUE" %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment