I defined several models: Journals, volumes, volume_scanInfo etc.
A journal can have more volumes and a volume can have more scanInfo.
What I want to do is:
- in the admin page of journals I want to have the list of the volumes inline (done)
- connect each volume of the previous list to its admin page where I can show the form to edit the volume and the list of its "scan info" inline.
so I want to have something like:
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>
Then
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>
What I tried to do is defining a model method that create the code and trying to use it inside the class that defines "volume inline" in the admin, but it doesn't work.
In other words
the model "Volume" has inside something like:
def selflink(self):
return '<a href="/admin/journaldb/volume/%s/">Full record</a>' % self.vid
selflink.allow_tags = True
and
class VolumeInline(admin.TabularInline):
fields = ['volumenumber', 'selflink']
model = Volume
extra = 1
But this gives the following error:
Exception Value: 'VolumeInline.fields' refers to field 'selflink' that is missing from the form.
Any idea?
Thanks,
Giovanni
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…