djangoの「スマート選択」アプリが正常に機能するようになっています。チェインされたフィールドの選択には値が設定されません。 githubの "readme"ファイル "https://github.com/digi604/django-smart-selects"には以下の指示があります。djangoスマート選択アプリ
- 連鎖フィールドは、同じモデル上のフィールドでも、連鎖する必要があります。
- 連鎖モデルフィールドは、連鎖フィールドによってもリンクされているモデルに対応する連鎖モデルのフィールドです。
私は指示が少しわかりにくく、大陸と郡のテーブルのモデルを表示しないようにしました。
私は以前に質問したことがありますが、私はこれに応答しませんでした。それは私の特定のモデルに関するより多くの情報を持っています。 "http://stackoverflow.com/questions/9155350/django-smart-selects-second-level-wont-populate"
「django-smart-select」エキスパートがあります。おかげ国= ChainedForeignKey()フィールドのための所与の例において
from smart_selects.db_fields import ChainedForeignKey
class Location(models.Model)
continent = models.ForeignKey(Continent)
country = ChainedForeignKey(
Country,
chained_field="continent",
chained_model_field="continent",
show_all=False,
auto_choose=True
)
area = ChainedForeignKey(Area, chained_field="country", chained_model_field="country")
city = models.CharField(max_length=50)
street = models.CharField(max_length=100)
それも私がそれを解釈した方法です。しかし、それは動作していません。 – BillB1951
遅れて申し訳ありませんが、はい、Countryクラスは大陸へのForeignKeyを持っている必要があります。AreaにはForeignKey to Country、CityにはForeignKeyがAreaに必要です。 – dragonx