V
V
valexeich2022-01-14 14:01:23
Python
valexeich, 2022-01-14 14:01:23

How to implement a system for adding to the list: I watch, I will watch, etc. as a registered user?

Hello everyone, I have a task and I don’t know how to solve it, I need that when I click a certain button on the anime page, the anime itself is added to the profile to a certain list, I’m watching, I’ll watch, etc., could you tell me how to implement this? I can't figure out how to make a model of it all.

Below is an example:

61e1579b9c628402838389.png
primer.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2022-01-14
@valexeich

From the database point of view, just a linked table or several. This is the classic many-to-many relationship.
There is a table "Users" with some primary key.
There is a table "Anime" with some kind of primary key.
If you make a separate linked table for each type of list (i.e. one for "watched" and one for "will watch"), then they will look like "user ID, anime ID", and the same two fields will be a composite primary key . The presence of a row in the table will mean that the specified user has added the specified anime to the list corresponding to the table.
Or you can make a general table "Lists", then its appearance will be slightly different - "User ID, anime ID, List type". If the user can put one anime in only one list, then the key will be as above, and if in several at the same time, then the key will be all three fields.
And how to do it in terms of models, read the documentation. This is one of the most basic things, if anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question