Skip to content

Instantly share code, notes, and snippets.

@gpg90
Created June 6, 2014 13:59
Show Gist options
  • Save gpg90/d8cf357df3b927cf13a2 to your computer and use it in GitHub Desktop.
Save gpg90/d8cf357df3b927cf13a2 to your computer and use it in GitHub Desktop.
@property
def _dict(self):
from django.db.models.query_utils import DeferredAttribute
exclude = [f.name for f in self._meta.fields if
isinstance(self.__class__.__dict__.get(f.attname),
DeferredAttribute)]
return model_to_dict(self, fields=[field.name for field in
self._meta.fields], exclude=exclude)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment