I can not get the second level (subcategory/E_cat) drop down to populate. First level (Category) seems to be working fine. I think I\'ve tried just about every reasonable combi
html.file
include the following if you are using forms
<script src="{% static 'smart-selects/admin/js/chainedfk.js' %}"></script>
<script src="{% static 'smart-selects/admin/js/chainedm2m.js' %}"></script>
models.py
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
admin.py
admin.site.register(Component)
admin.site.register(Group)
admin.site.register(Failure)
admin.site.register(Neighborhood)
UPDATE - MAY 2017
include this tag right after jQuery version 2 . It works perfrectly well in Django 1.10 and 1.11 version using python 3.5.2. Hope this helps you
<script type="text/javascript" src="{% static 'smart-selects/admin/js/chainedfk.js' %}"></script>
<script type="text/javascript" src="{% static 'smart-selects/admin/js/chainedm2m.js' %}"></script>
<script type="text/javascript" src="{% static 'smart-selects/admin/js/bindfields.js' %}"></script>
This looks alright. The problem might be that you haven't set up the smart_selects urls, or perhaps you're missing the javascript in your actual page.