I have that situation: I have models Item, Region and Country.
class Item(models.Model):
name = models.CharField(max_length=255)
alias = models.SlugField(unique=True)
country = models.OneToOneField(Country, default=0)
region = models.OneToOneField(Region, default=0, related_name='')
class Region(models.Model):
name = models.CharField(max_length=100)
country = models.ForeignKey(Country, default=0)
class Country(models.Model):
name = models.CharField(max_length=100)
When I add an item in the admin area and I select country I want to automatically build the region select with Regions
only from the selected Country
.
I know how to do it in javascript, but i don't know how CORRECT it is do that in Django.