Développement web python et django
Bonjour,
je fais un site de e-commerce sous python et django.
J'ai définit deux fichiers catalog_tags.py et catalog.html.
Voici le contenu de catalog_tags.py:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
from django import template
from cart import fonctions
from catalog.models import Category
register = template.Library()
@register.inclusion_tag("tags/cart_box.html")
def cart_box(request):
cart_item_count = fonctions.cart_distinct_item_count(request)
return {'cart_item_count': cart_item_count }
@register.inclusion_tag("tags/category_list.html")
def category_list(request_path):
result = Category.objects.all()
active_categories = Category.objects.filter(is_active=True)
return {'active_categories': active_categories,'request_path': request_path} |
Voici celui catalog.html
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
{% extends "base.html" %}
{% block site_wrapper %}
<div id ="main">
<a href="#content" class="skip_link">Skip to main content</a>
<div id="banner" >
<div class="bannerIEPadder">
<div class="cart_box">
{% cart_box request %}
</div>
Super market
</div>
</div>
<div id="navigation">
<div class="navIEPadder">
{% include "tags/navigation.html" %}
</div>
</div>
<div id="middle">
<div id="sidebar">
<div class="sidebarIEPadder">
[search box here]
<br/>
{% category_list %}
</div>
</div>
<div id="content">
<a name="content"></a>
<div class="contentIEPadder">
{% block content %}{% endblock %}
</div>
</div>
</div>
<div id="footer">
<div class="footerIEPadder">
[footer here]
</div>
</div>
</div>
{% endblock %} |
L'idée c'est que je veux afficher le resultat obtenu par les fonctions de catalog_tags.py dans le fichier catalog.html.
Malheureusement j'ai cette erreur:
TemplateSyntaxError Invalid block tag: 'cart_box', expected 'endblock'
Je ne sais vraiment pas résoudre cette erreur donc je viens solliciter votre aide.