Created
April 26, 2012 09:30
-
-
Save rromanchuk/2498121 to your computer and use it in GitHub Desktop.
Accessing setting constants in django, non idiotic way.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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