Added templatetag to only display enabled apps

This commit is contained in:
2010-04-05 03:19:29 +01:00
parent 586a2727b1
commit 87b4b01ec3
3 changed files with 24 additions and 0 deletions

View File

View 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