'django-admin startproject gives SyntaxError
I tried to start a new project with django 4.0 After installing Django in environment folder (Anaconda/envs/taskman) I created a new folder somewhere in my e: drive and by using windows command line created a new folder Django_site. Then from this folder I typed in command line prompt: django-admin startproject lifetool and got the following:
(taskman) E:\Projects\Django_site>django-admin startproject lifetool
Traceback (most recent call last):
File "E:\Programs\Anaconda\envs\taskman\Scripts\django-admin-
script.py", line 5, in <module>
from django.core.management import execute_from_command_line
File "E:\Programs\Anaconda\envs\taskman\lib\site-
packages\django\core\management\__init__.py", line 16, in <module>
from django.core.management.base import (
File "E:\Programs\Anaconda\envs\taskman\lib\site-
packages\django\core\management\base.py", line 13, in <module>
from django.core import checks
File "E:\Programs\Anaconda\envs\taskman\lib\site-
packages\django\core\checks\__init__.py", line 18, in <module>
import django.core.checks.translation # NOQA isort:skip
File "E:\Programs\Anaconda\envs\taskman\lib\site-
packages\django\core\checks\translation.py", line 3, in <module>
from django.utils.translation.trans_real import language_code_re
File "E:\Programs\Anaconda\envs\taskman\lib\site-
packages\django\utils\translation\trans_real.py", line 485
while (i := lang_code.rfind('-', 0, i)) > -1:
^
SyntaxError: invalid syntax
What is wrong? Do I need to correct invalid syntax in installed Django package? Help me to clarify the issue
Solution 1:[1]
I don“t know if you did it this way, but try to install django by the command python -m pip install Django
More info here
Solution 2:[2]
proper commands are:
python -m django --version
Django 4.0
django-admin startproject lifetool
the project structure will be
lifetool/
manage.py
lifetool/
__init__.py
settings.py
urls.py
asgi.py
wsgi.py
python manage.py runserver
BOOM server is running:
Django version 4.0, using settings 'lifetool.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | RubenL |
| Solution 2 |
