my problem: I have three models. il (province), ilce (district) and mahalle (neighborhood). I filter with smart-select. works smoothly in the entry of information. When I looked at the database, I saw that mahalle (neighborhood) data was recorded. but the mahalle (neighborhood) widget sounds empty.
my models:
class il(models.Model):
adi = models.CharField(max_length=20)
class ilce(models.Model):
ill = models.ForeignKey(il, on_delete=models.CASCADE)
adi = models.CharField(max_length=35)
class mahalle(models.Model):
ilcee = models.ForeignKey(ilce, on_delete=models.CASCADE)
adi = models.CharField(max_length=50)
class User(AbstractUser):
username = None
email = models.EmailField(_('email address'), unique=True)
.......
kurum_il = models.ForeignKey('il', on_delete=models.SET_NULL, null=True, blank=False)
kurum_ilce = ChainedForeignKey('ilce', chained_field="kurum_il", chained_model_field="ill", show_all=False, sort=False, null=True, blank=False)
kurum_mahalle = ChainedForeignKey('mahalle', chained_field="kurum_ilce", chained_model_field='ilcee', show_all=False, sort=False, null=True, blank=False)
Does not appear on the Admin page even though I enter and save neighborhood information related screenshot
Django-smart-selects looks long unmaintained with last release in 2018.
However there are few issues raised / discussed for it that may relate to your question, one of them #237. As a solution it has this Pull Request with little change to .js
file (actually it just comments out one line).
As it is not yet included in official release, you can apply these changes manually and provide new .js
file to override package one:
copy chainedfk.js from master branch to your project
place it at 'smart-selects/admin/js/chainedfk.js' path in your directory for static files:
place inside static
directory in your app and make this app appear before smart_selects
in INSTALLED_APPS
or use same static
directory or at another path by your preference but specify path to static
directory in STATICFILES_DIRS (more preferred, not depend on order in INSTALLED_APPS
)
edit this file, apply changes of this Pull Request and any other changes of your choice.