gpt4 book ai didi

python - 如果项目文件夹已经存在,则强制 django-admin startproject

转载 作者:IT老高 更新时间:2023-10-28 21:46:14 27 4
gpt4 key购买 nike

我想在已经存在的文件夹中启动新的 django 项目,显然得到

CommandError: '/home/user/projectfolder' already exists.

有没有办法强制 startproject 命令在现有文件夹中创建项目?我在那个文件夹和 git 文件夹中有一些重要数据,所以我不想把它移到某个地方然后再移回来。

最佳答案

使用当前目录即可:

cd /home/user/projectfolder

django-admin.py startproject project .

.的使用只是指示Django在当前目录下创建一个项目,而:

django-admin.py startproject

指示 Django 创建项目并创建必要的目录

If only the project name is given, both the project directory andproject package will be named and the project directorywill be created in the current working directory.

这失败是因为现有目录这不是错误,而是为了防止事故发生的限制。

关于python - 如果项目文件夹已经存在,则强制 django-admin startproject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31431924/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com