File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
project_home_tags/templatetags Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 33from django import template
44from django import VERSION as DJANGO_VERSION
55from django .conf import settings
6+ from django .core .exceptions import ValidationError
7+ from django .core .validators import URLValidator
68from django .utils .html import format_html
79
810if DJANGO_VERSION < (1 , 10 ):
@@ -20,10 +22,18 @@ def home_url():
2022
2123 Returns None if PROJECT_HOME_NAMESPACE is not defined in settings.
2224 """
25+ global home_namespace
2326 try :
2427 return reverse (home_namespace )
2528 except Exception :
26- return None
29+ try :
30+ validate_url = URLValidator ()
31+ if '://' not in home_namespace :
32+ home_namespace = 'http://' + home_namespace
33+ validate_url (home_namespace )
34+ return (home_namespace )
35+ except ValidationError :
36+ return None
2737
2838
2939def silence_without_namespace (f ):
You can’t perform that action at this time.
0 commit comments