{"id":23604,"library":"django-smart-selects","title":"django-smart-selects","description":"A Django application to handle chained model fields, allowing dropdowns to be dynamically filtered based on parent selections. Current version 1.7.2 (2024). Release cadence: irregular, with minor patches.","status":"active","version":"1.7.2","language":"python","source_language":"en","source_url":"https://github.com/jazzband/django-smart-selects","tags":["django","chained-selects","dynamic-fields","admin"],"install":[{"cmd":"pip install django-smart-selects","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Runtime dependency","package":"django","optional":false}],"imports":[{"note":"Older import path changed after 1.5.x; db_fields is correct for modern versions.","wrong":"from smart_selects.fields import ChainedForeignKey","symbol":"ChainedForeignKey","correct":"from smart_selects.db_fields import ChainedForeignKey"},{"note":"","wrong":"","symbol":"ChainedManyToManyField","correct":"from smart_selects.db_fields import ChainedManyToManyField"},{"note":"","wrong":"","symbol":"ChainedSelect","correct":"from smart_selects.widgets import ChainedSelect"}],"quickstart":{"code":"# models.py\nfrom django.db import models\nfrom smart_selects.db_fields import ChainedForeignKey\n\nclass Location(models.Model):\n    continent = models.CharField(max_length=100)\n\nclass Country(models.Model):\n    continent = models.ForeignKey(Location, on_delete=models.CASCADE)\n    name = models.CharField(max_length=100)\n\nclass City(models.Model):\n    country = ChainedForeignKey(\n        Country,\n        chained_field=\"continent\",\n        chained_model_field=\"continent\",\n        show_all=False,\n        auto_choose=True,\n        sort=True\n    )\n    name = models.CharField(max_length=100)\n\n# admin.py\nfrom django.contrib import admin\nfrom .models import City\n\nadmin.site.register(City)","lang":"python","description":"Basic usage: define a ChainedForeignKey in models and register in admin."},"warnings":[{"fix":"Avoid using limit_choices_to on chained fields.","message":"ChainedForeignKey does not work correctly with 'limit_choices_to' - the chain filtering overrides it. Use raw_id_fields instead if you need custom filtering.","severity":"gotcha","affected_versions":"all"},{"fix":"Remove the setting from settings.py.","message":"Setting SMART_SELECTS_USE_SELECCT2 in Django settings is deprecated as of 1.6.0; it is now always True.","severity":"deprecated","affected_versions":">=1.6.0"},{"fix":"Change imports to 'smart_selects.db_fields'.","message":"Versions before 1.5.3 used a different import path ('smart_selects.fields') which is removed in current versions.","severity":"breaking","affected_versions":"<1.5.3"},{"fix":"Use formset management form and ensure prefix is set.","message":"When using in formsets, the chained field may not update correctly because the JavaScript relies on element IDs. Ensure each form in the formset has a unique prefix.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use: from smart_selects.db_fields import ChainedForeignKey","cause":"Importing from wrong module (e.g., smart_selects.fields instead of smart_selects.db_fields).","error":"Unresolved reference 'ChainedForeignKey'"},{"fix":"Check that the chained_field name matches exactly a field on the foreign-key target model. Run makemigrations and migrate.","cause":"The chained_field argument points to a field that does not exist on the parent model, or the model hasn't been migrated.","error":"'NoneType' object has no attribute '_meta'"},{"fix":"Add 'smart_selects' to INSTALLED_APPS in settings.py.","cause":"Missing 'smart_selects' in INSTALLED_APPS.","error":"django.core.exceptions.ImproperlyConfigured: 'smart_selects' is not a valid application"},{"fix":"Ensure django-smart-selects static files are served. Check browser console for JS errors. If using jQuery 3+, it's supported since 1.5.3.","cause":"JavaScript not loaded or conflicts with other JS (e.g., jQuery version).","error":"ChainedSelect is not updating when parent changes"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}