I 'm working on a django app and i have a model with a datetimefield and in my view i accept data in json format which has date in time stamp , when i try to save the date in my model i get this error
"Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z]."
i tried to use this with no help :
date_converted_to_date_time_field = datetime.utcfromtimestamp(due_in_time_stamp )
my view looks like that :
@api_view(['POST', ])
def todo_list_api_view(request):
if request.method == 'POST':
due_in_time_stamp = int(request.data["due"])
date_converted_to_date_time_field = datetime.utcfromtimestamp(due_in_time_stamp ) # i pass it to a serializer to save the data in a model like that
serializer = mySerializer(data=request.data , context = {'user':request.user , 'due_date' : date_converted_to_date_time_field})
any help to achieve this ?