[英]How to create "add to favorites" functional using Django Rest Framework
I just can't find any information about the implementation of the system of adding to favorites for registered users.我只是找不到有关为注册用户添加到收藏夹的系统实施的任何信息。
The model has a Post model.该模型具有 Post 模型。 It has a couple of fields of format String
.它有几个格式为String
的字段。 The author
field, which indicates which user made the POST
request, etc. author
字段,指示哪个用户发出了POST
请求等。
But how to make it so that the user can add this Post to his “favorites”, so that later you can get a JSON
response with all the posts that he added to himself.但是如何做到让用户可以将此帖子添加到他的“收藏夹”中,以便稍后您可以获得包含他添加到自己的所有帖子的JSON
响应。 Well, respectively, so that you can remove from favorites.好吧,分别这样你就可以从收藏夹中删除。
Are there any ideas?有什么想法吗?
您可以在Author
模型中添加一个favorite_posts
字段(多对多)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.