from django.db import models from project.models import Project class Invoice(models.Model): project = models.ForeignKey(Project, on_delete=models.CASCADE) invoice_id = models.CharField(max_length=15) raised_date = models.DateField() due_date = models.DateField() paid_date = models.DateField(null=True, blank=True) is_archived = models.BooleanField() def __str__(self): return self.invoice_id class Item(models.Model): name = models.TextField(blank=False, null=False) amount = models.DecimalField() quantity = models.IntegerField() invoice = models.OneToOneField(Invoice, on_delete=models.CASCADE) def __str__(self): return self.name