我正在使用django-cms管理风格。通过遵循此处提到的解决方案,我设法更改了默认的DjangoCMS徽标:Django cms 3.4.1 admin dlogo
现在徽标是一个静态徽标,但是我希望它是动态徽标,这意味着它应该从存储位置的数据库中获取图像路径。
由于这些管理页面无法通过views.py呈现,因此我无法将查询集发送给它。
有人可以建议如何做吗?
使用context_processors
我们可以做到这一点。
首先需要得到这个:https : //github.com/divio/djangocms-admin-style/blob/master/djangocms_admin_style/templates/admin/inc/branding.html
branding.html文件必须放在admin / inc文件夹下的templates文件夹内,因此结构如下templates/admin/inc/branding.html
现在假设通过context_processor我们得到了company_logo
,它保存了数据库中的徽标URL。
那么在branding.html<div id="header-logo">
中将如下所示:
<div id="header-logo">
{% if company_logo %}
<a href="/"><img src="{{ company_logo.url }}" style="height:inherit;"></a>
{% else %}
<a class="icon-logo" href="/"><span>django CMS</span></a>
{% endif %}
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句