Skip to content
Browse files

Allow 'some.other.object.field' specification.

It is useful, if you want to output value of some child object's field in the
column.

Reviewed at http://reviews.reviewboard.org/r/3656/
  • Loading branch information...
1 parent fe298aa commit e02bd6260fba42cb287156fd23a785a72d8a5d99 @svetlyak40wt svetlyak40wt committed with davidt Dec 29, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 djblets/datagrid/grids.py
View
13 djblets/datagrid/grids.py
@@ -303,12 +303,15 @@ def render_data(self, obj):
self.data_cache[pk] = value
return value
else:
- value = getattr(obj, self.field_name)
+ # Follow . separators like in the django template library
+ value = obj
+ for field_name in filter(None, self.field_name.split('.')):
+ value = getattr(value, field_name)
- if callable(value):
- return value()
- else:
- return value
+ if callable(value):
+ value = value()
+
+ return value
def augment_queryset(self, queryset):
"""Augments a queryset with new queries.

0 comments on commit e02bd62

Please sign in to comment.
Something went wrong with that request. Please try again.