Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango InlineModelAdmin: Show partially an inline model and link to the complete model
    text
    copied!<p>I defined several models: Journals, volumes, volume_scanInfo etc.</p> <p>A journal can have more volumes and a volume can have more scanInfo.</p> <p>What I want to do is:</p> <ul> <li>in the admin page of journals I want to have the list of the volumes inline (done)</li> <li>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.</li> </ul> <p>so I want to have something like:</p> <pre><code>Journal #1 admin page [name] [publisher] [url] ..... list of volumes inline [volume 10] [..(other fields)..] &lt;a href="/link/to/volume/10"&gt;Full record&lt;/a&gt; [volume 20] [..(other fields)..] &lt;a href="/link/to/volume/20"&gt;Full record&lt;/a&gt; </code></pre> <p>Then</p> <pre><code>Volume #20 admin page [volume number] [..(other fields)...] ...... list of the scan info inline [scan info 33] [..(other fields)..] &lt;a href="/link/to/scaninfo/33"&gt;Full record&lt;/a&gt; [scan info 44] [..(other fields)..] &lt;a href="/link/to/scaninfo/44"&gt;Full record&lt;/a&gt; </code></pre> <p>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.</p> <p>In other words </p> <p>the model "Volume" has inside something like:</p> <pre><code>def selflink(self): return '&lt;a href="/admin/journaldb/volume/%s/"&gt;Full record&lt;/a&gt;' % self.vid selflink.allow_tags = True </code></pre> <p>and</p> <pre><code>class VolumeInline(admin.TabularInline): fields = ['volumenumber', 'selflink'] model = Volume extra = 1 </code></pre> <p>But this gives the following error:</p> <pre><code>Exception Value: 'VolumeInline.fields' refers to field 'selflink' that is missing from the form. </code></pre> <p>Any idea?</p> <p>Thanks, Giovanni</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload