[Django]-How to format dates and datetime in graphene

3👍

You can overwrite any field with DjangoObjectType. Your code may look like this.

class CustomType(DjangoObjectType):

   class Meta:
      model = CustomModel


   created_at = graphene.String()

   def resolve_created_at(self, info):
      return str(self.created_at.replace(microsecond=0))

For more details check out the docs

Leave a comment