请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

Field 'post_id' doesn't have a default value

创建回复的报错,因为post没有创建,而且post是不允许为空。创建的时候必须有一个值。

正在回答 回答被采纳积分+3

2回答

bobby 2018-12-30 12:58:19

https://img1.sycdn.imooc.com//szimg/5c28505d0001dec710460299.jpg 你这样设置一下 同时修改一下数据库中这个字段可以为空

1 回复 有任何疑惑可以回复我~
提问者 liyanan_nn 2018-12-27 20:09:40
async def post(self, comment_id, *args, **kwargs):
#添加回复
re_data = {}
param = self.request.body.decode("utf8")
param = json.loads(param)
form = CommentReplyForm.from_json(param)
if form.validate():
try:
comment = await self.application.objects.get(PostComment, id=int(comment_id))
replyed_user = await self.application.objects.get(User, id=form.replyed_user.data)

reply = await self.application.objects.create(PostComment, user=self.current_user, parent_comment=comment,
replyed_user=replyed_user, content=form.content.data)


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号