When I tried to run this command:
python manage.py createsuperuser in my Django project, it gave me a super long error which included the following:
File “manage.py”, line 22, in
File “manage.py”, line 18, in main
File “/Users/username/.local/share/virtualenvs/django-learn-csZU2bYZ/lib/python3.8/site-packages/django/core/management/init.py”, line 364, in execute_from_command_line
ImportError: cannot import name ‘path’ from ‘django.urls’ (/Users/username/.local/share/virtualenvs/django-learn-csZU2bYZ/lib/python3.8/site-packages/django/urls/init.py)
The problem in my case was that I had the wrong version of Django installed. In order to run the
python manage.py createsuperuser command you need at least Django 2.
Run this command to check the version of Django you are currently working with:
python -m django --version
Run this command to install the latest version of Django.
pip install --upgrade django
python -m django --version command again and make sure your new Django version is 2.x or above. If so, you should be able to run
python manage.py createsuperuser now