I'm designing a payment system for a website, but I have trouble. A person can do a Payment and that Payment has a payment type, for example, debit card, credit card or PayPal. So, I need the possibility to add new payment options. The problem is I don't know how to link these two tables, I know that I need a third table with only the
payment_id and the
payment_type_id assigned. Is there a way to generate this with Django?
class PaymentType(models.Model): """Payment option available""" name = models.CharField(unique=True, max_length=255) created_on = models.DateTimeField(auto_now_add=True) active = models.BooleanField(default=False) def __str__(self): return self.name class Payment(models.Model): class PaymentStatus(models.TextChoices): DONE = '1', "DONE" PENDENT = '2', "PENDENT" CANCELED = '3', "CANCELED" status = models.CharField(max_length=10, choices=PaymentStatus.choices, default=PaymentStatus.PENDENT) # payment type created_on = models.DateTimeField(auto_now_add=True)