采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
创建回复的报错,因为post没有创建,而且post是不允许为空。创建的时候必须有一个值。
你这样设置一下 同时修改一下数据库中这个字段可以为空
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)
登录后可查看更多问答,登录/注册
异步IO并发编程/Form,ORM/aiomysql、peewee-async/epoll
1.4k 18
2.3k 15
1.6k 15
1.5k 12
2.3k 11
购课补贴联系客服咨询优惠详情
慕课网APP您的移动学习伙伴
扫描二维码关注慕课网微信公众号