plateforme-tfjm2/apps/member/templatetags/getconfig.py

26 lines
494 B
Python

from django import template
import os
from member.models import Config
def get_config(value):
"""
Return a value stored into the config table in the database with a given key.
"""
config = Config.objects.get_or_create(key=value)[0]
return config.value
def get_env(value):
"""
Get a specified environment variable.
"""
return os.getenv(value)
register = template.Library()
register.filter('get_config', get_config)
register.filter('get_env', get_env)