Registry / web-framework / django-smart-selects

django-smart-selects

JSON →
library1.7.2pypypiunverified

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.

pip install django-smart-selects
INSTALL
IMPORT
SIG · DJANGO-SMART-SELEC
D
django-smart-selects
web-frameworkpythonv1.7.2
Install
3.4s avg
Import
—
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.7.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.6MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.4s · import 0.000s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ChainedForeignKey
✓ from smart_selects import ChainedForeignKey
✗ from smart_selects.db_fields import ChainedForeignKey

Basic usage: define a ChainedForeignKey in models and register in admin.

# models.py from django.db import models from smart_selects.db_fields import ChainedForeignKey class Location(models.Model): continent = models.CharField(max_length=100) class Country(models.Model): continent = models.ForeignKey(Location, on_delete=models.CASCADE) name = models.CharField(max_length=100) class City(models.Model): country = ChainedForeignKey( Country, chained_field="continent", chained_model_field="continent", show_all=False, auto_choose=True, sort=True ) name = models.CharField(max_length=100) # admin.py from django.contrib import admin from .models import City admin.site.register(City)
Debug
Known issues
gotchaChainedForeignKey does not work correctly with 'limit_choices_to' - the chain filtering overrides it. Use raw_id_fields instead if you need custom filtering.
fix
Avoid using limit_choices_to on chained fields.
affects: all
deprecatedSetting SMART_SELECTS_USE_SELECCT2 in Django settings is deprecated as of 1.6.0; it is now always True.
fix
Remove the setting from settings.py.
affects: >=1.6.0
breakingVersions before 1.5.3 used a different import path ('smart_selects.fields') which is removed in current versions.
fix
Change imports to 'smart_selects.db_fields'.
affects: <1.5.3
gotchaWhen 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.
fix
Use formset management form and ensure prefix is set.
affects: all
Upgrade
Version history
1.7.2latest on PyPI · released Nov 17, 2024
Audit
Dependencies
djangorequiredRuntime dependency
Agent activity
11 hits · last 30 days
node
11
Resources
django-smart-selects — pip install django-smart-selects · libregistry