This is a question related to django. How to insert data for each user.

Asked 2 years ago, Updated 2 years ago, 47 views

I'm working on a project through django I created a timetable app.

If you log in to your super account,

Enter the schedule here.

If you put in each class, you'll get a timetable

I want to have each user with this kind of data, but what should I do? <

We have the login membership function.

django

2022-09-22 18:45

1 Answers

It is time for each user to create a users_schedules table that stores the relationship between which subjects they put in their timetable.

For example, if user number 3 includes subject number 2 in the first period and subject number 4 in the sixth period, you can put these records on the table.

id (PK, a_i)  userId (FK)    scheduleId (*FK)    scheduleOrder (index)
(Omitted) 320
(Omitted) 3, 4, 5

Then, you will be able to retrieve user 3's timetable with the next query.
select * from users_schedules where userId = 3 order by scheduleOrder

Hint: At this point, the schedules table is convenient to think of as a list of subjects that each user can take.


2022-09-22 18:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.