編輯:請不要誤導這個問題,這是我的錯,我的變化,不工作。我碰巧需要命名爲相同的項目(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'不是..它在另一個目錄中...... –