diff --git a/sso/templatetags/__init__.py b/sso/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sso/templatetags/installed.py b/sso/templatetags/installed.py new file mode 100644 index 0000000..01a68a7 --- /dev/null +++ b/sso/templatetags/installed.py @@ -0,0 +1,20 @@ +from django import template +from django.conf import settings +from django.template.defaultfilters import stringfilter + +register = template.Library() + +@register.filter +@stringfilter +def installed(value): + apps = settings.INSTALLED_APPS + if "." in value: + for app in apps: + if app == value: + return True + else: + for app in apps: + fields = app.split(".") + if fields[-1] == value: + return True + return False diff --git a/templates/base.html b/templates/base.html index 7c8b1b0..9de6e3c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,3 +1,5 @@ +{% load installed %} +
@@ -17,7 +19,9 @@