Django创建app项目报错:TypeError: unsupported operand type(s) for /: ‘str‘ and ‘str‘

解决Django项目中创建App时出现TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’的问题。通过修改settings.py文件中的'DIRS'配置路径解决。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Django创建app项目报错:TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’

新创建了一个Django项目,使用指令:

python manage.py startapp app01

创建app项目的时候,却报错。

报错截图如下:

image-20210726163126175

解决办法:

修改settings.py文件中的’DIRS’配置

原先配置是:
'DIRS': [BASE_DIR / 'templates']
修改为:
'DIRS': [str.format(BASE_DIR, '/templates')]
或者:
'DIRS': [os.path.join(BASE_DIR,'templates')],

都可以达到效果。

image-20210726163352219

问题解决:

image-20210726163532931

image-20210726163549391

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值