1👍
Try Django Clever Selects
https://github.com/PragmaticMates/django-clever-selects
I use it in my Django 1.6 project
👤Y.N
0👍
Your structure is incorrect I am giving you an example that works
class Continent(models.Model):
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class Country(models.Model):
continent= models.ForeignKey(Continent)
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class City(models.Model):
continent= models.ForeignKey(Continent)
country= ChainedForeignKey(Country, chained_field="continent", chained_model_field="continent", show_all=False, auto_choose=True, sort=True)
name = models.CharField(max_length=255)
def __str__(self):
return self.name
class Neighborhood(models.Model):
continent= models.ForeignKey(Continent)
country= ChainedForeignKey(Country, chained_field="continent", chained_model_field="continent", show_all=False, auto_choose=True, sort=True)
name = models.CharField(max_length=255)
city= ChainedForeignKey(City, chained_field="country", chained_model_field="country", show_all=False, auto_choose=True, sort=True)
name = models.CharField(max_length=255)
def __str__(self):
return self.name
- [Answer]-Django + wsgi = Forbidden 403
- [Answer]-Python Django: Load Autofield to MySql Table using loaddata
- [Answer]-Django; Why empty_label is not shown in ModelChoiceField?
Source:stackexchange.com