How can i create datetime2 model on Django

55 Views Asked by At

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?

1

There are 1 best solutions below

0
Furkan Bulut On BEST ANSWER

The problem was releated with timezone.To solution:

  • Upload mssql-django
  • Set timezone ( USE_TZ = False ) as false in django settings, model created as datetime2.