Add common.utils.return_related function to support double underscore related model references.
Signed-off-by: Michael Price <loneviking72@gmail.com>
This commit is contained in:
committed by
Roberto Rosario
parent
0edb028bbf
commit
e3d400c70d
@@ -149,6 +149,15 @@ def return_attrib(obj, attrib, arguments=None):
|
||||
return force_text(exception)
|
||||
|
||||
|
||||
def return_related(instance, attribute):
|
||||
"""
|
||||
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)
|
||||
|
||||
|
||||
def urlquote(link=None, get=None):
|
||||
"""
|
||||
This method does both: urlquote() and urlencode()
|
||||
|
||||
Reference in New Issue
Block a user