📜  django 将数据插入数据库外键 view.py - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:55.107000             🧑  作者: Mango

代码示例1
for i in range(1,10):
        obj = Count.objects.filter(userId=request.user.id, channelId=cid)
        if not obj:
            news_obj = News_Channel.objects.get(id=i)
            o = Count.objects.create(id=Count.objects.all().count() + 1,userId=request.user.id, channelId=news_obj,rate=0)
            o.save()
        i += 1