Add default option to dbsetting template tag

This commit is contained in:
Kumi 2020-04-16 09:51:48 +02:00
parent d40cde2aef
commit 89cd57c2bd
3 changed files with 7 additions and 4 deletions

3
.gitignore vendored
View file

@ -2,3 +2,6 @@
*.pyc
__pycache__/
migrations/
build/
dist/
django_dbsettings.egg-info/

View file

@ -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
def dbsetting(key, default=""):
return getValue(key, default)

View file

@ -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