Don't process the AttributeError exception but let calling code handle it.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -123,7 +123,6 @@ def resolve(path, urlconf=None):
|
||||
|
||||
|
||||
def return_attrib(obj, attrib, arguments=None):
|
||||
try:
|
||||
if isinstance(attrib, types.FunctionType):
|
||||
return attrib(obj)
|
||||
elif isinstance(
|
||||
@@ -139,20 +138,15 @@ def return_attrib(obj, attrib, arguments=None):
|
||||
return result()
|
||||
else:
|
||||
return result
|
||||
except Exception as exception:
|
||||
if settings.DEBUG:
|
||||
return 'Attribute error: %s; %s' % (attrib, exception)
|
||||
else:
|
||||
return force_text(exception)
|
||||
|
||||
|
||||
def return_related(instance, attribute):
|
||||
def return_related(instance, related_field):
|
||||
"""
|
||||
This functions works in a similar method to return_attrib but is
|
||||
meant for related models. Support multiple levels of relationship
|
||||
using double underscore.
|
||||
"""
|
||||
return reduce_function(getattr, attribute.split('__'), instance)
|
||||
return reduce_function(getattr, related_field.split('__'), instance)
|
||||
|
||||
|
||||
def urlquote(link=None, get=None):
|
||||
|
||||
Reference in New Issue
Block a user