# 添加 Fruit.objects.create(name='Apple') # 更新 UserProfile.objects.filter(user=admin).update(**{'online':False,'channel':''}) # 保存或者更新 defaults 用来更新/保存 user=admin用来查询 UserProfile.objects.update_or_create(defaults={'user':admin, 'online':True, 'channel':self.channel_name },user=admin) # 查询 # 单查询 User.objects.get(id=self.admin_id) # 全部和多查询 Membership.objects.all() UserProfile.objects.filter(user=admin) #删除 Line.objects.filter(admin_id=self.admin_id).delete()
来源:https://www.cnblogs.com/Mvloveyouforever/p/10521347.html