mirror of
https://github.com/nikdoof/test-auth.git
synced 2026-01-30 16:08:14 +00:00
Added templatetag to only display enabled apps
This commit is contained in:
0
sso/templatetags/__init__.py
Normal file
0
sso/templatetags/__init__.py
Normal file
20
sso/templatetags/installed.py
Normal file
20
sso/templatetags/installed.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user