Thursday, December 31, 2020

How to make relationship in django models in such scenario So,here i want to make Invoicemgmt model in which i can have multiple entries for Invoice table having customer,project and Invoice_amount.

Basically,requirement is that whenever i see 'view_Invoice' of some id,first i will see all data of that specific id on that page and then i want to have small table below for invoice_mgmt,where i can add amount received for that specific id invoice.

*so,i want to know what fields should i add in invoice_mgmt model for relationship "

class Invoice(models.Model):      company_choice = (          ('VT_India', 'VT_India'),          ('VT_USA', 'VT_USA'),      )      company = models.CharField(          max_length=30, blank=True, null=True, choices=company_choice)      customer = models.ForeignKey(Customer, on_delete=models.CASCADE)      project = models.ForeignKey(Allproject, on_delete=models.CASCADE)        invoice_title = models.CharField(max_length=15)        invoice_id = models.IntegerField(primary_key=True)      invoice_amount = models.IntegerField()      invoice_date = models.DateField(          blank=True, null=True)      invoice_duedate = models.DateField(          blank=True, null=True)        invoice_description = models.TextField()        def __str__(self):          return self.invoice_title      class Paymentmethod(models.Model):      paymentmethod_id = models.IntegerField(primary_key=True)      paymentmethod_name = models.CharField(max_length=15)        def __str__(self):          return self.paymentmethod_name      class Invoicemgmt(models.Model):      invoicemanagement_id = models.IntegerField(primary_key=True)      invoice_received = models.IntegerField()      date = models.DateField(          blank=True, null=True)      payment_method = models.ForeignKey(Paymentmethod, on_delete=models.CASCADE)

"So, basically i want to have multiple entries in invoice mgmt table for one specific invoice table id(one specific data)"

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

1 comment: