错误场景:
删除创建的 project 及app 后重新创建 app后报
CommandError: %app% conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.
原因:
From the django-admin () startapp <app_label> [destination] django-admin startapp Creates a Django app directory structure for the given app name in the current directory or the given destination. By default the directory created contains a models.py file and other app template files. (See the source for more details.) If only the app name is given, the app directory will be created in the current working directory. If the optional destination is provided, Django will use that existing directory rather than creating a new one. You can use ‘.’ to denote the current working directory. For example: django-admin startapp myapp /Users/jezdez/Code/myapp
解决方法:
# first create a Project (container). django-admin.py startproject Project # create multiple apps cd Project python manage.py startapp polls python manage.py startapp hello
参考:
https://stackoverflow.com/questions/7019070/cannot-start-any-django-app
错误场景: 删除创建的 project 及app 后重新创建 app后报 CommandError: %app% conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name. 原因: From the django-admin () startapp
[destination] django-admin startapp Creates a Django app directory structure for the given app name in the current directory or the given destination. By default the directory created contains a models.py file and other app template files. (See the source for more details.) If only the app name is given, the app directory will be created in the current working directory. If the optional destination is provided, Django will use that existing directory rather than creating a new one. You can use ‘.’ to denote the current working directory. For example: django-admin startapp myapp /Users/jezdez/Code/myapp 解决方法: # first create a Project (container). django-admin.py startproject Project # create multiple apps cd Project python manage.py startapp polls python manage.py startapp hello 参考: https://stackoverflow.com/questions/7019070/cannot-start-any-django-app