Skip to content

Instantly share code, notes, and snippets.

@glenrobertson
Created December 2, 2011 00:50
Show Gist options
  • Save glenrobertson/1421081 to your computer and use it in GitHub Desktop.
Save glenrobertson/1421081 to your computer and use it in GitHub Desktop.
# only show the fields specified in the json properties list of the model
if hasattr(item, 'json_properties'):
json_properties = getattr(item, 'json_properties')
properties = {}
for k,v in item.__dict__.iteritems():
if k in json_properties:
properties[k] = v
# the json properties list is not available, so copy all the properites
else:
properties = item.__dict__.copy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment