我可以编辑Django管理屏幕来显示我的html吗? [英] Can I edit the Django administration screen to display my html?
问题描述
例如,假设我有一个编程语言模型,对于django管理员页面中的每种语言,在编辑字段部分下方显示一个带有HTML段落的图片。 Python语言将显示一条蛇图片和一些关于它的描述。
谢谢Alon。
覆盖管理员 change_form.html
为
{%extendsadmin / change_form.html $}
{%block after_related_objects%}
{#将你的HTML放在这里#$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ pre>
(Django 1.8 note)确保您在TEMPLATES dict(settings.py)中指定了DIRS键$ /
'DIRS':[
os.path.join(BASE_DIR,'templates'),
],
templates /
---- admin / / p>
-------- app_name /
----------- -modelname /
---------------- change_form.html
Is there a way to display html data on a specific page in the django administrator feature?
For example, let's say I have a programming-language Model, and for each language in the django administrator page, beneath the editing fields section, it display a picture with an html paragraph. A 'Python' language will show a snake picture and some description about it.
Thanks, Alon.
解决方案 Override admin change_form.html
for your model with
{% extends "admin/change_form.html" %}
{% block after_related_objects %}
{# put your html here #}
{% endblock %}
(Django 1.8 note) Make sure you have specified 'DIRS' key in TEMPLATES dict (settings.py)
'DIRS': [
os.path.join(BASE_DIR, 'templates'),
],
templates/
----admin/
--------app_name/
------------modelname/
----------------change_form.html
这篇关于我可以编辑Django管理屏幕来显示我的html吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!