adding instances from django admin

Viewed 206

This is how my classes look.

class School(models.Model):
    state = models.ForeignKey(State, on_delete=models.CASCADE)
    region = models.ForeignKey(Region, on_delete=models.CASCADE)
    cluster = models.ForeignKey(Cluster, on_delete=models.CASCADE)
    school_name = models.CharField(max_length=250)
    facilitator = models.CharField(max_length=250)
    f_number = models.IntegerField()
    f_email = models.EmailField()
    school_logo = models.FileField(default='')
    school_strength = models.IntegerField()

In which state, region, cluster are also classes. I have tried to create a network of schools with classification in 3 levels i.e state, region, cluster. I have assumed that when I add schools from django admin I thought it might filter regions if I select state and filter clusters when I select region so that it would be easy. But It doesn't seem to work. Though after selecting a particular state and region while adding a school in the cluster dropdown all the clusters from all the states and regions are coming.

Is there a solution for this or as of now we don't have such option in django?

1 Answers
Related