0

In Django Admin I have a Product model that has foreign keys of other models. The default add Product form didn't display the name of the choices so I create custom forms to display the names.

In the default add Product page I could add a model to use for the product I am adding. I would like to have that ability as well as see the names of my choices.

Also I use a foreign key that has a pair of unique attributes (name and version). Currently I am setting choices to

REVISIONS = [(revision, revision.name) for revision in Revision.objects.all()]

I would like to be able to see both the name and the version, something like this

REVISIONS = [(revision, revision.name + revision.version) for revision in Revision.objects.all()]
4

1 に答える 1

0

ユニコード(自己)メソッドを追加するだけで、管理メニューに名前が表示され、使用する外部キーを追加できるデフォルトのフォームを使用できます。

于 2013-03-19T18:09:17.353 に答える