Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 扩展admin index.html模板_Python_Html_Django_Templates - Fatal编程技术网

Python 扩展admin index.html模板

Python 扩展admin index.html模板,python,html,django,templates,Python,Html,Django,Templates,我从admin.contrib下载了以下模板:base.html、base_site.html和index.html 我想扩展index.html,但无论我做什么,它似乎都不起作用 在settings.py中,我声明了我的应用程序的名称,以覆盖管理文件的呈现顺序。因此,我可以编辑实际的文件,并且在运行服务器时内容确实会发生变化 但是,我在templates/admin/foo.html目录中创建了一个文件 带有foo.html的代码是: {% extends "admin/index.html"

我从admin.contrib下载了以下模板:base.html、base_site.html和index.html

我想扩展index.html,但无论我做什么,它似乎都不起作用

在settings.py中,我声明了我的应用程序的名称,以覆盖管理文件的呈现顺序。因此,我可以编辑实际的文件,并且在运行服务器时内容确实会发生变化

但是,我在templates/admin/foo.html目录中创建了一个文件

带有foo.html的代码是:

{% extends "admin/index.html" %}

{% block something %}
<p>Hello</p>
{% endblock %}
{%extends“admin/index.html”%}
{%block something%}
你好

{%endblock%}
我已经将文件templates/admin/index.html更改为
{%block something%}{%end block%}

当我运行服务器时,foo.html的内容不会显示

我是否需要将foo.html添加到我的url.py并在views.py中创建一个函数来呈现内容


任何帮助都将不胜感激。

Foo.html
不被Django管理员识别。如果要自定义
admin/index.html
,请在
admin/index.html
中进行更改

如果要使用单独的文件,请将其包含在
admin/index.html
中,如下所示:

{% include "foo.html" %}

希望有帮助

谢谢,这确实有效。我是否能够使用views.py函数将数据加载到“foo.html”中?我希望“foo.html”能够显示一些数据,并且有一个表单可以提交数据。这是一个完全不同的问题,我们没有足够的细节。如果你发布了你想要完成的事情,以及你想要在管理中获得的所有视图和数据,我们可以看一看我希望仍然拥有Django管理的默认功能。但是,在“主”管理页面上,我想显示数据库中的特定条目。需要根据一些条件检查特定条目。我假设这必须在views.py文件的函数中完成。我面临的问题是将其传递给“foo.html”。我可以在管理员页面加载时调用AJAX,并使用jquery填充页面,但我更喜欢使用Django模板来实现这一点。我希望这能解释我想要达到的目标。@CallumOsborn我相信AJAX是解决这个问题的方法。