Import error datetime_safe

ImportError: cannot import name ‘datetime_safe’ from ‘django.utils’ (C:\Users\Omar.virtualenvs\vidly-SAfzz8MZ\Lib\site-packages\django\utils_init_.py)

I have got this error everytime I try to run the server following the django web application section in the python course this happened after the part where we install “django-tastypie” in the api section

at the beginning of the course was told to install Django 2.6 or something like that I guess, which is not supported and not working anymore with python 3.11 so I installed the latest version of Django to solve this issue but then found out that ‘datetime_safe’ no longer supported in the new versions of Django so I uninstalled Django then installed version 4.1 and it solved the problem
I wanted to post the solution not delete the post in case someone get the same issue later in the future

1 Like

thanks, I had the same issue.

Great initiative!

I had the same problem, for someone who just wants the commands:

pip install django==4.1.*

python manage.py runserver

1 Like