2016-04-20 8 views
0

includeタグを付けてbase.htmlにテンプレートを追加する際にエラーメッセージが表示されます。その他のテンプレートは問題なく正しくレンダリングされますが、追加しようとすると問題が発生します。エラーは次のとおりです。includeタグのDjangoテンプレートエラー

RuntimeError at/
maximum recursion depth exceeded in __instancecheck__ 
Request Method: GET 
Request URL: http://127.0.0.1:8000/ 
Django Version: 1.8.5 
Exception Type: RuntimeError 
Exception Value:  
maximum recursion depth exceeded in __instancecheck__ 
Exception Location: C:\Python27\lib\site-packages\django\template\base.py in __init__, line 743 
Python Executable: C:\Python27\python.exe 
Python Version: 2.7.11 
Python Path:  
['C:\\Users\\TOSHIBA\\market\\market', 
'C:\\WINDOWS\\SYSTEM32\\python27.zip', 
'C:\\Python27\\DLLs', 
'C:\\Python27\\lib', 
'C:\\Python27\\lib\\plat-win', 
'C:\\Python27\\lib\\lib-tk', 
'C:\\Python27', 
'C:\\Python27\\lib\\site-packages', 
'c:\\python27\\lib\\site-packages'] 

私が追加しようとしている私のテンプレートが含まれています:

{% extends 'base.html' %} 
{% block content %} 
    <!-- recommend slider --> 
    <section class="recommend container"> 
    <div class="recommend-product-slider small-pr-slider wow bounceInUp"> 
     <div class="slider-items-products"> 
     <fieldset class="box-title"> 
     <legend>Recommended </legend> 
     </fieldset> 
     <div id="recommend-slider" class="product-flexslider hidden-buttons"> 
      <div class="slider-items slider-width-col3"> 
      {% include 'products/product.html' with object_list=products col_class_set="col-sm-2" %} 


      </div> 
     </div> 
     </div> 
    </div> 
    </section> 
    <!-- End Recommend slider --> 

{% endblock content %} 

次のように私のbase.htmlコードは次のとおりです。

{% load static %} 
{% load staticfiles %} 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<!--[if IE]> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<![endif]--> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<meta name="description" content="Dressika Theme"> 
<meta name="author" content="Harira Ijaz"> 
<title>Dressika Online Shopping Store</title> 
<!-- Favicons Icon --> 
<link rel="icon" href="{% static 'images/favicon.png' %}" type="image/x-icon" /> 
<link rel="shortcut icon" href="{% static 'images/favicon.png' %}" type="image/x-icon" /> 
<!-- Mobile Specific --> 
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
<!-- CSS Style --> 
<link rel="stylesheet" href="{% static 'css/animate.css' %}" type="text/css"> 
<link rel="stylesheet" href="{% static 'css/bootstrap.min.css' %}" type="text/css"> 
<link rel="stylesheet" href="{% static 'css/style.css' %}" type="text/css"> 
<link rel="stylesheet" href="{% static 'css/revslider.css' %}" type="text/css"> 
<link rel="stylesheet" href="{% static 'css/owl.carousel.css' %}" type="text/css"> 
<link rel="stylesheet" href="{% static 'css/owl.theme.css' %}" type="text/css"> 
<link rel="stylesheet" href="{% static 'css/font-awesome.css' %}" type="text/css"> 
<link rel="stylesheet" href="{% static 'css/product-detail.css' %}" type="text/css"> 
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet"> 

<!-- Google Fonts --> 
<link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,300,700,800,400,600' rel='stylesheet' type='text/css'> 
</head> 

<body class="cms-index-index"> 
<div class="page"> 


{% include 'header.html' %} 

{% include 'navbar.html' %} 
</div> 

    <!-- header service --> 

    <!-- end header service --> 


{% include 'slider.html' %} 
{% include 'offerbanner.html' %} 
{% include 'container.html' %} 

{% include 'featured.html' %} 
{% include 'trending.html' %} 


{% include 'middleslider.html' %} 

{% include 'recommend.html' %} 
{% include 'latestblog.html' %} 
{% include 'footer.html' %} 


</div> 
{% include 'java.html' %} 
</body> 
</html> 

答えて

1

あなたのテンプレートはbase.htmlから延びこれはテンプレートを含める必要があります。テンプレートはbase.htmlから拡張する必要があります。テンプレートはbase.htmlから拡張する必要があるテンプレートを含める必要があり、次にテンプレートからインクルードする必要があります。 .html ...

{% extends 'base.html' %}を含むテンプレートからブロックへの参照を削除してください。

+0

エラーがなくなり、ホームページが正常に表示されます。しかし、私が 'recommendations.html'に含まれているテンプレートはホームページに商品を表示していません。それについて何か考えていますか? –

+0

@HariraIjaz - 「object_list」として渡されるものには何の問題もないかもしれませんが、それは別の質問ですので、必要ならば新しい質問をする必要があります。この回答が* this *の問題を解決するのに役立った場合は、それを受け入れることを検討する必要があります。 – Sayse

関連する問題