-
创建项目
-
命令
-
项目名不要使用汉字 数字开头
-
-
创建应用
-
命令
-
一定要进入到项目里创建应用
-
-
启动项目时
-
(null): can't open file 'manage.py': [Errno 2] No such file or directory
-
没有在django项目中启动
-
-
-
迁移时
-
No changes detected
-
没有在配置文件中注册app
-
-
Did you install mysqlclient?
-
在项目同名的目录下的init.py中加入
import pymysql pymysql.install_as_MySQLdb()
-
-
(1045, "Access denied for user 'sunna'@'localhost' (using password: NO)")
-
在配置文件中主要看数据库的配置
-
-
(2003, "Can't connect to MySQL server on 'localhost1' ([Errno 11001] getaddrinfo failed)")
-
数据库配置时HOST:"localhost"
-
-
(1049, "Unknown database 'django0708'")
-
在mysql中没有创建数据库
-
-
在mysql中查看所有表时为空
-
执行迁移文件
-
-
当在mysql中查看表结构只有1个字段时,和模型类中的字段不相符时
-
在模型类时每个字段之间使用逗号隔开了
-
-
如果已经生成迁移文件,但是需要重新迁移时
-
将生成的迁移文件删掉,数据库也删掉重新弄
-
-
-
写视图时
-
'ModelBase' object is not iterable 去视图中看一下queryset是否写错
-
TemplateDoesNotExist: rest_framework/api.html
-
没有在配置文件中注册drf框架
-
-
'str' object has no attribute 'values' 写序列化器时没有加元类
-
当数据表中有数据但是在看效果时数据没有渲染出来
-
看一下视图中 模型类、序列化器、想实现的效果是否对应
-
-
AttributeError at /cate/ Got AttributeError when attempting to get a value for field `name` on serializer `FoodSer`.The serializer field might be named incorrectly and not match any attribute or key on the `Food_Cate` instance.Original exception text was:'Food_Cate' object has no attribute 'name'.
-
主要看一下序列化器是否对应
-
-
-
路由错误
-
The included URLconf '<module 'django.urls' >
-
在主路由文件中导入子路由出错 看和路由相关的文件
-
-
python (后端错误)
于 2022-07-19 17:15:23 首次发布