Skip to content

Commit

Permalink
Merge b02f8c7 into 73ac3c0
Browse files Browse the repository at this point in the history
  • Loading branch information
nmandery committed Oct 28, 2015
2 parents 73ac3c0 + b02f8c7 commit 1de0ce4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion rest_framework_gis/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ def get_properties(self, instance, fields):
if field.write_only:
continue
value = field.get_attribute(instance)
properties[field.field_name] = field.to_representation(value)
value_repr = None
if value is not None:
value_repr = field.to_representation(value)
properties[field.field_name] = value_repr

return properties

Expand Down
1 change: 1 addition & 0 deletions tests/django_restframework_gis_tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class BaseModel(models.Model):
name = models.CharField(max_length=32)
slug = models.SlugField(max_length=128, unique=True, blank=True)
timestamp = models.DateTimeField(null=True, blank=True)
geometry = models.GeometryField()
objects = models.GeoManager()

Expand Down
4 changes: 2 additions & 2 deletions tests/django_restframework_gis_tests/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Meta:
model = Location
geo_field = 'geometry'
id_field = 'slug'
fields = ('name', 'slug')
fields = ('name', 'slug', 'timestamp')


class LocationGeoFeatureFalseIdSerializer(LocationGeoFeatureSerializer):
Expand Down Expand Up @@ -98,7 +98,7 @@ class Meta:
model = BoxedLocation
geo_field = 'geometry'
bbox_geo_field = 'bbox_geometry'
fields = ['name', 'details', 'id']
fields = ['name', 'details', 'id', 'timestamp']


class LocationGeoFeatureBboxSerializer(gis_serializers.GeoFeatureModelSerializer):
Expand Down
1 change: 1 addition & 0 deletions tests/django_restframework_gis_tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def test_geojson_format(self):
'details': "http://testserver/geojson/%s/" % location.id,
'name': 'geojson test',
'fancy_name': 'Kool geojson test',
'timestamp': None,
'slug': 'geojson-test',
},
'geometry': {
Expand Down

0 comments on commit 1de0ce4

Please sign in to comment.