Accessing setting constants in django, non idiotic way.
This file contains 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