Skip to content

Commit

Permalink
#89: Only convert to string for datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Oct 14, 2019
1 parent 6ae5616 commit a99cc3a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion common/models/db_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import enum

from datetime import datetime
from sqlalchemy import Index, Column, BigInteger, String, DateTime, ForeignKey, Integer, Float, FetchedValue, \
TypeDecorator
from sqlalchemy.ext.declarative import declarative_base
Expand Down Expand Up @@ -48,7 +49,8 @@ def to_dict(self):
"""
dictionary = {}
for column in self.__table__.columns:
dictionary[column.name] = str(getattr(self, column.name))
attribute = getattr(self, column.name)
dictionary[column.name] = str(attribute) if isinstance(attribute, datetime) else attribute
return dictionary

def to_nested_dict(self, includes):
Expand Down

0 comments on commit a99cc3a

Please sign in to comment.