graphene-django/graphene_django/rest_framework/models.py
B4rtware 6a19ab5a4b
use to_representation in favor of get_attribute (#848)
* use `to_represenation` in favor of `get_attribute`

* fix datetime type does get converted to a string

to_representation will convert the datetime field into a string representation. However the to_representation on the method field will only call its underlying method.

* fix add missing import

* apply black formatter

* add test for serializer method field

* apply black format

* improve backward compatibility

by using date's class contructor instead of fromisostring

* apply black format

* fix black format issue
2020-02-21 17:42:47 +00:00

17 lines
436 B
Python

from django.db import models
class MyFakeModel(models.Model):
cool_name = models.CharField(max_length=50)
created = models.DateTimeField(auto_now_add=True)
class MyFakeModelWithPassword(models.Model):
cool_name = models.CharField(max_length=50)
password = models.CharField(max_length=50)
class MyFakeModelWithDate(models.Model):
cool_name = models.CharField(max_length=50)
last_edited = models.DateField()