Revision 68a8935f
b/snf-astakos-app/astakos/im/util.py | ||
---|---|---|
264 | 264 |
return (i for i in vars(obj.__class__) \ |
265 | 265 |
if isinstance(get_class_attr(obj.__class__, i), property)) |
266 | 266 |
|
267 |
def model_to_dict(obj, exclude=['AutoField', 'ForeignKey', 'OneToOneField'], |
|
268 |
include_empty=True): |
|
267 |
def model_to_dict(obj, exclude=None, include_empty=True): |
|
269 | 268 |
''' |
270 | 269 |
serialize model object to dict with related objects |
271 | 270 |
|
... | ... | |
273 | 272 |
date: January 31, 2011 |
274 | 273 |
http://djangosnippets.org/snippets/2342/ |
275 | 274 |
''' |
275 |
|
|
276 |
if exclude is None: |
|
277 |
exclude = ['AutoField', 'ForeignKey', 'OneToOneField'] |
|
276 | 278 |
tree = {} |
277 | 279 |
for field_name in obj._meta.get_all_field_names(): |
278 | 280 |
try: |
Also available in: Unified diff