Take a look at the documentation here: http://www.django-rest-framework.org/api-guide/fields/#datetimefield
Signature: DateTimeField (format = None, input_formats = None)
format - A string representing the output format. If not specified, this default value matches the value for the DATETIME_FORMAT parameter, which will be "iso-8601" if not set. Setting to a format string indicates that the return values ββto_representation should be forced into the string output. Format strings are described below. Setting this value to None means Python datetime objects must be returned to_representation. In this case, the datetime encoding will be determined by the renderer.
When None is used for the datetime format, objects will be returned to_representation, and the final presentation of the output will be determined by the rendering class.
In the case of JSON, this means that the datetime representation uses the ECMA 262 timeline specification by default. This is a subset of ISO 8601 that uses millisecond precision and includes the suffix βZβ for the UTC time zone, for example: 2013-01-29T12: 34: 56.123Z .
So the UTC (Z) representation of your datetime object is actually the default behavior.
When you create or update a model instance through Djangorest, the serializer will be called using data kwarg, which does not happen if you use a list or a detailed view.
In both cases, your view will return serializer.data . In the case of the create / update operation, this will be the view of serializer.validated_data , while in the case of the list / detail operation it will be a direct view of the instance.
In both cases, the representation is achieved by calling field.to_representation with kwarg format=None by default, which forces the field to return the value of a simple string.
The magic happens here :
- create / update : checking returns an object corresponding to the time zone that includes your standard time zone. It converts to a string by calling its
isoformat() method and returns as is. - list / retrieve : ORM django saves the timestamp as UTC. It converts to a string by calling the
isoformat() method , but DRF replaces +00:00 with Z (see link above).
So, to get the desired result with a timezone offset, you can pass format=None or the strftime custom string to DateTimeField in your serializer. However, you will always get UTC time from +00:00 , because this is what the data (fortunately) is stored as.
If you want the actual offset to be 'Asia/Kolkata' , you probably have to define your own DateTimeField :
from django.utils import timezone class CustomDateTimeField(serializers.DateTimeField): def to_representation(self, value): tz = timezone.get_default_timezone()