0

So i have a model like this

class ExaminationCenter(models.Model):
    district = models.ForeignKey(District, on_delete=models.CASCADE)
    name = models.CharField(max_length=50)

    def __str__(self):
        return self.name

And another model like this

class ExamForm(models.Model):
    exam_centre_1 = models.ForeignKey(ExaminationCenter, on_delete=models.cascade)
    exam_centre_2 = models.ForeignKey(ExaminationCenter, on_delete=models.cascade)
    exam_centre_3 = models.ForeignKey(ExaminationCenter, on_delete=models.cascade)

Is there any way to make these three fields to hold the unique item from the same foreign key model.

For example if user choose a exam center in exam_center_1 then that examination center should not be available for exam_center_2 and exam_center_3

Aman
  • 131
  • 2
  • 11

1 Answers1

2

go look up the onetoonefield and onetomanyfield in django doc. or look through this stackoverflow

lvingstone
  • 171
  • 8