Jin Nii Sama
Jin Nii Sama

Reputation: 747

Django rest framework combine/nested serializer

I have 2 table, appointment and schedule.

schedule has these field: scheduleid, title, 'starttime', 'endtime', 'date'

appointment has these field: id, scheduleid, clinicid, 'time', 'queueNo', 'date'

schedule starttime is = appointment time. So is the date

When ever a user create a Appointment, it will also create a schedule as u can see on above. I know how to make a nested serializer but what i do not know is. If a schedule hasn't been created, what do i insert the scheduleid in the appointment table.

Reason is because, create appointment first, how to create so that in appointment django know how to create a scheduleid for it ?

Upvotes: 1

Views: 195

Answers (1)

Sakthi Panneerselvam
Sakthi Panneerselvam

Reputation: 1397

You need to create a appointment table first and after the confirmation create schedule table. So remove the scheduleid from appointment instead of that add appointmentid to schedule table. This is not the only way, it's suggestion from side based on your requirements.

Upvotes: 1

Related Questions