Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.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
Django子模板-Base.html未呈现_Html_Django_Django Templates - Fatal编程技术网

Django子模板-Base.html未呈现

Django子模板-Base.html未呈现,html,django,django-templates,Html,Django,Django Templates,我在我的应用程序中使用了Django模板系统,在子模板中,我相应地引用了{%extends“base.html”%},尽管在重新命名模板时,它只会显示html标记,没有css样式,因此不会完全使用base.html模板。 请说明我做错了什么?。找不到my base.html模板的位置可能会有问题吗 这是子模板代码: {% extends "base.html" %} {% block content %} {% for field in form %} {{ form }} {% endfo

我在我的应用程序中使用了Django模板系统,在子模板中,我相应地引用了{%extends“base.html”%},尽管在重新命名模板时,它只会显示html标记,没有css样式,因此不会完全使用base.html模板。 请说明我做错了什么?。找不到my base.html模板的位置可能会有问题吗

这是子模板代码:

{% extends "base.html" %}
{% block content %} 
{% for field in form %}
{{ form }} 
{% endfor %} 
{% endblock %}
这是base.html模板代码(相关部分):


页面标题-这就是功能所在。。。
{%block primary%}{%endblock%}
如果您需要更多信息来解决此问题,请告诉我

-我将在今晚(伦敦时间)添加views.py--

这些都整理好了,非常感谢你的帮助

谢谢

就像Golliney提到的那样。。。 您需要在base.html文件中有一个

{% block content %}
{% endblock %}
然后,您可以在扩展base.html模板的其他模板中覆盖它

当前在子模板中,您可以执行以下操作:

{% block primary %}
whatever you want here and this would show up where you marked on the base.html template
{% endblock %}
也不确定你是否只是简单地列出了一个例子。您将需要创建

<form action="" method="post">{% csrf_token %} 
for loop here
</form>
{%csrf\u令牌%}
在这里循环

如果缺少样式(CSS)以及静态文件夹中的样式,这可能就是问题所在。基本模板是否正常工作(包括CSS的正确渲染)单独使用?为什么要为每个表单字段呈现相同的表单?Hi Jingo/Josvic基本模板单独使用CSS样式效果很好-我想我缺少了一些子模板的CSS样式,这是否需要应用于例如.block内容?父模板和子模板中的块名称应该相同。这样子模板就可以知道要填充父模板的哪一部分。
<form action="" method="post">{% csrf_token %} 
for loop here
</form>