Skip to content

Instantly share code, notes, and snippets.

@aezell
Created April 5, 2011 15:43
Show Gist options
  • Save aezell/903860 to your computer and use it in GitHub Desktop.
Save aezell/903860 to your computer and use it in GitHub Desktop.
def render_data(self, obj):
if isinstance(obj,dict):
value = obj.get(self.id, None)
if not value and 'fields' in obj: # added
value = obj['fields'].get(self.id, None) # added
else:
value = getattr(obj,self.id, None)
if callable(value):
return self.format_data(value())
else:
return self.format_data(value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment