标签:bsp 方法 rgs 一对多 http auth image pos inf
1.一对一和一多对多是一样的,多对多不太一样
2.增 post
class BookView(APIView):
def post (self,request,*args,**kwargs):
publish=Publish.objects.filter(pk=1).first()
author=Author.objects.filter(pk=1)
Book.objects.create(book_name="红楼",publish=publish) # 自动关联出版社,publish_id ,publish 也可以
#方法2,新增数据
book_objects=Book(book_name="aa",publish=publish,authors=author)
book_objects.save()
# 删除
Publish.objects.filter(pk=2).delete()
# 修改
Book.objects.filter(pk=1).update(publish_id=1)
标签:bsp 方法 rgs 一对多 http auth image pos inf
原文地址:https://www.cnblogs.com/SunshineKimi/p/13800505.html