From 89cd57c2bd212c17126f5cb12c63bfc3d1881616 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Thu, 16 Apr 2020 09:51:48 +0200 Subject: [PATCH] Add default option to dbsetting template tag --- .gitignore | 3 +++ dbsettings/templatetags/dbsetting.py | 6 +++--- setup.cfg | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 63c4b8b..872942b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *.pyc __pycache__/ migrations/ +build/ +dist/ +django_dbsettings.egg-info/ diff --git a/dbsettings/templatetags/dbsetting.py b/dbsettings/templatetags/dbsetting.py index 1e8e315..1d04611 100644 --- a/dbsettings/templatetags/dbsetting.py +++ b/dbsettings/templatetags/dbsetting.py @@ -1,8 +1,8 @@ from django import template -from dbsettings.models import Setting +from dbsettings.functions import getValue register = template.Library() @register.simple_tag -def dbsetting(key): - return Setting.objects.get(key=key).value # pylint: disable=no-member \ No newline at end of file +def dbsetting(key, default=""): + return getValue(key, default) diff --git a/setup.cfg b/setup.cfg index d50746e..751c6c2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = django-dbsettings -version = 0.8 +version = 0.8.1 description = A Django app to store key-value pairs in the database long_description = file: README.md url = https://kumig.it/kumisystems/dbsettings