问题描述
我正在尝试实施 django-smart-selects,但 Docs 中未涵盖我的情况。 它们涵盖了两种情况 - 那些是
class Continent(models.Model):
name = models.CharField(max_length=255)
class Country(models.Model):
continent = models.**ForeignKey**(Continent)
name = models.CharField(max_length=255)
class Location(models.Model):
continent = models.ForeignKey(Continent)
country = models.ForeignKey(Country)
area = models.ForeignKey(Area)
city = models.CharField(max_length=50)
street = models.CharField(max_length=100)
和
class Continent(models.Model):
name = models.CharField(max_length=255)
class Country(models.Model):
continent = models.**ManyToMany**(Continent)
name = models.CharField(max_length=255)
class Location(models.Model):
continent = models.ForeignKey(Continent)
country = models.ForeignKey(Country)
area = models.ForeignKey(Area)
city = models.CharField(max_length=50)
street = models.CharField(max_length=100)
但是,我的场景看起来像这样 - 有一个额外的直通模型;
class Continent(models.Model):
name = models.CharField(max_length=255)
class Country(models.Model):
continent = models.**ManyToMany**(Continent,through='CountryToContinent")
name = models.CharField(max_length=255)
class CountryToContinent(models.Model):
continent = models.ForeignKey(Continent)
name = models.ForeignKey(Country)
class Location(models.Model):
continent = models.ForeignKey(Continent)
country = models.ForeignKey(Country)
area = models.ForeignKey(Area)
city = models.CharField(max_length=50)
street = models.CharField(max_length=100)
在 django admin 中,我已经注册了 Location
模型,并且我有一个 tabular inline
带有 continent
和国家/地区字段,但是由于存在直通模型,链式选择不起作用。任何指导或提示将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)