[Answer]-Django smart selects

1👍

Try Django Clever Selects

https://github.com/PragmaticMates/django-clever-selects

I use it in my Django 1.6 project

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

Leave a comment