Here is my example :
We have printers. We can define page formats that are linked to a specific printer then we define workflows that select a starting format (first page added to the printing job), a body format and an end format (last page added to the printing job).
Start and End are not required (null and blank = True)
I want to be sure that start, body and end will be formats of the same printer.
class Printer(models.Model):
name = models.CharField(max_length = 20)
class Format(models.Model):
name = models.CharField(max_length = 20)
format = models.TextField()
printer = models.ForeignKey(Printer)
class Workflow(models.Model):
name = models.CharField(max_length = 20)
startfmt = models.ForeignKey(Format, related_name = 'start_workflow', null = True, blank = True)
bodyfmt = models.ForeignKey(Format, related_name = 'start_workflow')
endfmt = models.ForeignKey(Format, related_name = 'start_workflow', null = True, blank = True)
So I need this model to validate that startfmt, bodyfmt and endfmt reference formats that share the same printer... how ?