我定义了几个模型:期刊,卷,volume_scanInfo等.
日志可以拥有更多卷,而卷可以拥有更多scanInfo.
我想做的是:
所以我希望有类似的东西:
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>
Run Code Online (Sandbox Code Playgroud)
然后
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>
Run Code Online (Sandbox Code Playgroud)
我尝试做的是定义一个模型方法,该方法创建代码并尝试在管理中定义"volume inline"的类中使用它,但它不起作用.
换一种说法
模型"卷"有类似于:
def selflink(self):
return '<a href="/admin/journaldb/volume/%s/">Full record</a>' % self.vid
selflink.allow_tags = True
Run Code Online (Sandbox Code Playgroud)
和 …
尽管我喜欢django文档,但管理员中关于bookmarklet的部分却很奇怪.
我的问题是这样的:如果我在视图中并且我有一个django模型(或者,在某些情况下,是一个实际的对象),我怎样才能到达该模型(或对象)的相关管理页面?如果我有对象coconut_transportation.swallow.objects.all()[34],我怎么能直接跳到管理页面来编辑那个特定的燕子?
同样,如何获取管理页面的URL以添加另一个吞咽?