我有一個問題讓django「智能選擇」應用程序正常工作。它不會填充我的鏈接字段的選擇。 github上的「readme」文件「https://github.com/digi604/django-smart-selects」給出了以下說明。django智能選擇應用程序
- 鏈接字段是相同模型上的字段,該字段也應鏈接。
- 鏈式模型字段是鏈式模型的字段,它與由鏈式字段鏈接的模型相對應。
我發現說明有點神祕,他們沒有顯示大陸和縣表的模型,使其更容易。
我有一個關於這個我沒有得到迴應發佈的上一個問題。它有關於我的具體模型的更多信息。 「http://stackoverflow.com/questions/9155350/django-smart-selects-second-level-wont-populate」
希望有一些「django智能選擇」專家,可以讓我過駝峯。感謝
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 2012-02-08 02:43:21
對不起,對於遲到的回覆,但是,是的,Country類需要有一個到Continent的ForeignKey,Area需要一個ForeignKey到Country,City需要一個ForeignKey到Area,等等。 – dragonx 2012-02-12 19:37:03