Skip to content

Commit

Permalink
fix created and updated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nllong committed Jun 11, 2019
1 parent 61ca7e9 commit 6b1dd0a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions seed/serializers/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
required approvals from the U.S. Department of Energy) and contributors.
All rights reserved. # NOQA
:author Paul Munday <paul@paulmunday.net>
:author Nicholas Long <nicholas.long@nrel.gov>
"""
import json
import pytz
from collections import OrderedDict

from django.db import models
Expand Down Expand Up @@ -105,6 +107,10 @@ def to_representation(self, data):

class PropertySerializer(serializers.ModelSerializer):

# The created and updated fields are in UTC time and need to be casted accordingly in this format
created = serializers.DateTimeField("%Y-%m-%dT%H:%M:%S.%fZ", default_timezone=pytz.utc)
updated = serializers.DateTimeField("%Y-%m-%dT%H:%M:%S.%fZ", default_timezone=pytz.utc)

class Meta:
model = Property
fields = '__all__'
Expand Down Expand Up @@ -256,6 +262,7 @@ class PropertyViewSerializer(serializers.ModelSerializer):
labels = PropertyLabelsField(read_only=True, many=True)

state = PropertyStateSerializer()
property = PropertySerializer()

class Meta:
model = PropertyView
Expand Down

0 comments on commit 6b1dd0a

Please sign in to comment.