我已经阅读了有关如何customize models的文档。我想添加一个额外的网址。在
extra_url = models.URLField(max_length=200, blank=True, null=True)
在Django管理中一切都很好,但是我不知道如何在实际的HTML中调用该字段。在
文件上说:
The above code is enough to start entering tags in the admin interface. To use/display them in the front end, you will also need to override Photologue’s own templates - as the templates are likely to be heavily customised for your specific project, an example is not included here.
我已经用我自己的模板覆盖了Photologue的模板。我是个新手,没有例子就搞不懂。我一直在猜测,运气不好。在
^{pr2}$
您是否完全按照文档创建额外的模型,即:
如果是-则可以在模板中编写
{{ gallery.extended.extra_url }}
来显示新字段。在关键是
related_name
,它告诉Django如何从现有的库中访问新模型,并且您已经在模板中以变量{{ gallery }}
访问新模型。在相关问题 更多 >
编程相关推荐