python - Parsing model fields in Django REST Framework -
i have simple django model datetime field i'm building django rest framework. django saves datetime fields in format resembles 2014-12-07t17:00:00z
. possible parse field in serializer when pull in api response it's in proper format?
# serializer class eventserializer(serializers.modelserializer): class meta: model = events depth = 1 # view class eventviewset(viewsets.modelviewset): queryset = events.objects.all() serializer_class = eventserializer # model class events(models.model): title = models.charfield(max_length=250) content = models.textfield(blank=true, null=true) date = models.datetimefield(blank=true, null=true) location = models.foreignkey(locations, related_name='events') def __unicode__(self): return unicode(self.title) class meta: verbose_name_plural = 'events'
Comments
Post a Comment