运行django项目遇到的问题

一、TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’

创建好Django项目,编写hello world,准备运行查看,却报如下错误,只需要查看settings.py文件,进行如下就该即可。
在这里插入图片描述

将 ‘DIRS’: [BASE_DIR / ‘templates’], 修改为 ‘DIRS’: [os.path.join(BASE_DIR, ‘templates’)],即可。

然后启动服务器,又出现如下错误

二、RuntimeError: maximum recursion depth exceeded in cmp

在这里插入图片描述
查看functools.py文件(双击报错的蓝色链接),
将截图上{}内的代码替换为如下内容即可在这里插入图片描述

lt’: [(‘gt’, lambda self, other: not (self < other or self
== other)),
(‘le’, lambda self, other: self < other or self == other),
(‘ge’, lambda self, other: not self < other)],
le’: [(‘ge’, lambda self, other: not self <= other or self == other),
(‘lt’, lambda self, other: self <= other and not self == other),
(‘gt’, lambda self, other: not self <= other)],
gt’: [(‘lt’, lambda self, other: not (self > other or self == other)),
(‘ge’, lambda self, other: self > other or self == other),
(‘le’, lambda self, other: not self > other)],
'ge ': [(‘le’, lambda self, other: (not self >= other) or self == other),
(‘gt’, lambda self, other: self >= other and not self == other),
(‘lt’, lambda self, other: not self >= other)]

再次启动服务器:
在这里插入图片描述
正常启动!!!访问127.0.0.1:8000/hello/查看内容
在这里插入图片描述

好的,下面是 Django 项目部署到服务器并运行的具体步骤: 1. 将 Django 项目代码上传到服务器。您可以使用 FTP、SCP 或其他文件传输协议将代码上传到服务器,或者使用 Git 等版本控制工具进行代码部署。 2. 安装 Django 及相关依赖。在服务器上使用 pip 安装 Django 及相关的依赖库,如 Pillow、psycopg2 等。 3. 设置数据库。在服务器上创建数据库及相应的用户,并修改 Django 项目的 settings.py 文件中的数据库配置。 4. 配置 Web 服务器。您可以使用 Apache 或者 Nginx 等 Web 服务器来部署 Django 项目,具体配置方式可参考相关文档。在配置完成后,需要启动 Web 服务器。 5. 配置静态文件。在 settings.py 文件中配置静态文件路径,并使用 collectstatic 命令将静态文件收集到指定的目录。 6. 配置应用服务器。您可以使用 uWSGI 或者 Gunicorn 等应用服务器来启动 Django 项目,具体配置方式可参考相关文档。在配置完成后,需要启动应用服务器。 7. 运行 Django 项目。在服务器上启动 Web 服务器和应用服务器后,您可以在浏览器中输入服务器的 IP 地址或域名来访问 Django 项目。 需要注意的是,在部署过程中,可能会遇到各种问题,例如数据库连接失败、Web 服务器启动失败、应用服务器启动失败等等。因此,建议在部署前先做好相关的测试,并逐一排查问题
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值