1.‘QuerySet’ object has no attribute ‘name’

解决原因:1.settings里面忘了添加restframework .
2;模型序列化器fields字段值没有用双引号
2.序列化器输出时候继承GenericAPIView,响应值用Response报错
解决原因:由于导入response时误导入的时request模块的,其实应该导入drf里面的response
3.启动django项目时,接口展示无页面渲染

解决原因是因为settings里面的DEBUG = False 改为true就好了
一旦把DEBUG设为False之后, runserver服务不再提供静态文件服务

解决原因是需要设置一个read_only字段,上面的图是没有刷新服务
project=serializers.SlugRelatedField(slug_field=‘tester’,read_only=True)
报错
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server ver
sion for the right syntax to use near '(6) NOT NULL)' at line 1"))
解决原因是Django2.1不再支持MySQL5.5,必须5.6版本以上
在初期建表时经常会遇到想要改字段的情况,但是改完后执行迁移命令发现每次都是 No migrations to apply.
,后来发现在数据库里

在这个表里找到你要迁移的表名删掉那一行记录,再重新迁移
1095



被折叠的 条评论
为什么被折叠?



