startapp时出现 CommandError错误

startapp时出现 CommandError: 'xxxxx' conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name.错误

原因可能是在settings.py中加入了

sys.path.append(os.path.join(BASE_DIR, 'app'))

解决办法,先将上面这行代码注释掉

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'django_filters',
    'users',
    'goods',
    'order',
    'ckeditor',
    'ckeditor_uploader',
]

并将创建的应用名称前,加上路径app,例如'app.users'

再使用 python manage.py  startapp app_name ./apps/app_name 创建

startapp成功后,修改回去可以了

posted @ 2023-07-13 19:41  笑而不语心自闲  阅读(409)  评论(0编辑  收藏  举报