Skip to content

Commit

Permalink
Merge branch 'release/0.8.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlov99 committed May 18, 2015
2 parents 0cb1961 + 460e535 commit 884143e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
2015-05-18 Kirill Pavlov <kirill.pavlov@phystech.edu>

* Allow serialization of fields not defined in model, but in resource.

2015-04-20 Kirill Pavlov <kirill.pavlov@phystech.edu>

* Add request logger.
Expand Down
2 changes: 1 addition & 1 deletion jsonapi/__init__.py
@@ -1,5 +1,5 @@
""" JSON:API realization."""
__version = (0, 8, 7)
__version = (0, 8, 8)

__version__ = version = '.'.join(map(str, __version))
__project__ = PROJECT = __name__
6 changes: 3 additions & 3 deletions jsonapi/serializers.py
Expand Up @@ -99,18 +99,18 @@ def dump_document(cls, instance, fields_own=None, fields_to_many=None):
document = {}
# Include own fields
for fieldname in fields_own:
value = getattr(instance, fieldname)
field_serializer = getattr(
cls, "dump_document_{}".format(fieldname), None)

if field_serializer is not None:
value = field_serializer(instance)
else:
value = getattr(instance, fieldname)
try:
field = instance._meta.get_field(fieldname)
except models.fields.FieldDoesNotExist:
# Field is property
value = getattr(instance, fieldname)
# Field is property, value already calculated
pass
else:
if isinstance(field, models.fields.files.FileField):
# TODO: Serializer depends on API here.
Expand Down

0 comments on commit 884143e

Please sign in to comment.