编辑:请不要误导这个问题,这是我的错,我的变化,不工作。我碰巧需要命名为相同的项目(not a smart idea
),这使我感到困惑,因为我正在从一个不同的项目中进行更改,对此我误导了很好的stackoverflow人员。为什么模板继承失败?
我有一个基本模板public_base.html
<!doctype html>
<!-- [if IE ]> <html class="no-js"> <![endif] -->
<head>
<!-- favicon for web browser and smartphones -->
<link rel="icon" href="{{ STATIC_URL }}images/img.png" type="image/x-png">
<link rel="apple-touch-icon" href="{{ STATIC_URL }}img/apple-touch-icon.png">
<!-- Google Fonts -->
<link href='http://fonts.googleapis.com/css?family=Homenaje|Molengo' rel='stylesheet' type='text/css'>
<!-- CSS Section -->
<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}maincss/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}maincss/impress.css">
<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}maincss/style.css">
<link type="text/css" rel="stylesheet" href="{{ STATIC_URL }}maincss/impression.css">
<title>{% block title %}F4L | Have it easy{% endblock %}</title>
</head>
<body lang="en">
<div id="container">
{% load smartmin %}
<div id="header"> <!-- Header -->
<div id="logo">
<a href="{% url homepage %}">
<img src="{{ STATIC_URL }}img/logo.jpg" class="" alt="" />
</a>
</div>
<div id="menu">
<ul>
{% if perms.restaurant_detail.restaurant_detail.create %}
<li><a href="#">Join F4L</a></li>
{% endif %}
<li><a href="#">FAQ</a></li>
<li><a href="#">contact</a></li>
<li><a href="#">about us</a></li>
{% if request.user.is_authenticated %}
<li><a href="{% url users.user_logout %}">logout</a></li>
{% else %}
<li><a href="{% url users.user_login %}">login</a></li>
{% endif %}
</ul>
</div>
</div> <!-- End Header -->
<div style="clear: both;"></div>
<div id="main"> <!-- Main -->
{% block main-contents %}
<p>jrneflkwnel</p>
{% endblock %}
</div>
</div>
,我这里继承,home.html
{% extends "public_base.html" %}
{% block main-contents %}
<p>This is not Working.</p>
{% endblock main-contents %}
但这不工作,基本上都在home.html
内容不加载。这可能是什么原因造成的?
做到了这一点,仍然没有改变... –
这两个模板都在你的'templates'文件夹的根目录吗? –
nope,'home.html'不是..它在另一个目录中...... –