How to create an order with also seller as a foreign key to the orders table similar to customer field?

Viewed 20

Here is some customization, I am trying to achieve. In creating rest API’s using DRF section, for the orders API, while creating orders we are getting the user id or creating one if it not exists from the customer object. Now, consider there is another model seller which has same foreign key relationship similar to customer field to the orders table.

Now what to do in this situation to create an order? How to get the user id with both customer and seller in the serializer and what changes has to be done for the view?

Whole orders api is the same, just I have added the sellers model with three fields sellername, phone and foreign key to user model.

[models.py][1]
[serializer.py][2]
[views.py][3]

As you can see when I only pass the customer object, I am getting the user id back so how to implement also for seller object

0 Answers
Related