Answer the question
In order to leave comments, you need to log in
How to serialize a datetime object?
Good afternoon.
Model:
class Challenge(models.Model):
owner = models.ForeignKey(User)
distance = models.FloatField(default=0)
time = models.FloatField(default=0)
start_date = models.DateTimeField()
end_date = models.DateTimeField()
new_challenge = Challenge.objects.create(owner_id=token.user_id, distance=distance, time=time, start_date=datetime.datetime.fromtimestamp(int(challenge["start_date"])/1000.0), end_date=datetime.datetime.fromtimestamp(int(challenge["end_date"])/1000.0))
data = {
"data": new_challenge_serializer.data
}
reg_id = [notification.notification_id]
gcm.json_request(registration_ids=reg_id, data=data)
Answer the question
In order to leave comments, you need to log in
Create the desired property in the model and add it to the serializer
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question