I'm building a website for a friends's art exhibition. I currently define a model called Participant, every participant should also be able to log in to the system, so when a Participant is created a new User is also created.
我正在为朋友的艺术展建立一个网站。我目前定义了一个名为Participant的模型,每个参与者也应该能够登录系统,因此在创建参与者时,还会创建一个新用户。
Now when editing or creating a new Participant, I would like to be able to display certain fields from User such as email address for example. So that someone using the admin only has to edit Participant and the linked User will be updated.
现在,在编辑或创建新的参与者时,我希望能够显示来自用户的某些字段,例如电子邮件地址。因此,仅使用管理员的人必须编辑参与者,并且将更新链接的用户。
My problem is displaying these fields in the admin. I have tried to add e-mail as a property of the Participant model, that looks up its value from the related User, but these aren't displayed in the Admin. I also tried to define my own admin form for this model, however I can't get it prepopulated as this only works with fields.
我的问题是在管理员中显示这些字段。我尝试将电子邮件添加为Participant模型的属性,该模型从相关用户查找其值,但这些不会显示在管理员中。我也尝试为这个模型定义我自己的管理表单,但是我无法预先填充它,因为这只适用于字段。
From my googling so far it looks like prepopulating admin forms is not possible in the current version, using properties like fields doesn't seem to work either or at least not the way I want it.
到目前为止,从我的谷歌搜索,看起来在当前版本中不可能预先填充管理表单,使用像字段这样的属性似乎不起作用或者至少不是我想要的方式。
Could anyone point me in the right direction?
有人能指出我正确的方向吗?
David