CentOS 8.3 第一个Django项目

1. 版本问题,Python3.8.0,PyCharm2020.3.2没有问题,但django的版本只能用2版本,我用的是2.16,使用3.0以上的Django会报错,一般是Sqlite3的问题;

2.自动生成的django项目中,settings文件中

 TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']

代码中红色的 / 会报错,

File "/Data/Myproject/dj01/dj01/settings.py", line 58, in <module>
    'DIRS': [BASE_DIR / 'templates']
TypeError: unsupported operand type(s) for /: 'str' and 'str'

将'DIRS': [BASE_DIR / 'templates']改为'DIRS': [BASE_DIR'templates']

问题解决

猜你喜欢

转载自blog.csdn.net/tswang6503/article/details/112788483
8.3