sql-serverdjangodjango-modelsdatetime2

How can i create datetime2 model on Django


I do some research about this topic but i cannot find a solution.

`CreatedDate=models.DateTimeField(auto_now_add=True)`

when i create a model using this code, data type of mssql set as datetimeoffset(7).But i wish to create as type of datetime2(7).

I tried django-mssql-backend library.(It set as datetimeoffset(7)).I was expected datetime2.

https://stackoverflow.com/questions/65600327/sql-datetime27-field-to-django I followed the instructions here but the solution did not work for me

Shortly, how can i create datetime2 with using Django model?


Solution

  • The problem was releated with timezone.To solution: