我定义了几个模型:日志(log)、卷、volume_scanInfo等.
日志(log)可以有更多卷,卷可以有更多scanInfo.
我想做的是:
- 在期刊的管理页面中,我想让卷列表内联(完成)
- connect each volume of the previous list to its admin page where I can show the form to edit the volume 和 the list of its "scan info" inline.
所以我想要像这样的东西:
Journal #1 admin page
[name]
[publisher]
[url]
.....
list of volumes inline
[volume 10] [..(other fields)..] <a href="/link/to/volume/10">Full record</a>
[volume 20] [..(other fields)..] <a href="/link/to/volume/20">Full record</a>
然后
Volume #20 admin page
[volume number]
[..(other fields)...]
......
list of the scan info inline
[scan info 33] [..(other fields)..] <a href="/link/to/scaninfo/33">Full record</a>
[scan info 44] [..(other fields)..] <a href="/link/to/scaninfo/44">Full record</a>
我try 做的是定义一个创建代码的模型方法,并try 在定义管理员中"内联卷"的类中使用它,但它不起作用.
换句话说
"体积"模型的内部 struct 如下:
def selflink(self):
return '<a href="/admin/journaldb/volume/%s/">Full record</a>' % self.vid
selflink.allow_tags = True
和
class VolumeInline(admin.TabularInline):
fields = ['volumenumber', 'selflink']
model = Volume
extra = 1
但这会产生以下错误:
Exception Value: 'VolumeInline.fields' refers to field 'selflink' that is missing from the form.
有什么 idea 吗?
谢谢, 乔瓦尼