3
我想創建包含標籤並將其放置在頁面上,但它不工作。django inclusion_tag
我views.py:
from django.shortcuts import render_to_response, redirect
from django import template
register = template.Library()
@register.inclusion_tag('weather.html')
def weather():
return {'city': 'angola'}
def home(request):
return render_to_response('index.html')
的index.html
<title> TITLE </title>
Hi everyone!
{% weather %}
weather.html
weather is fine in {{city}}
Django的調試頁說, 「無效的塊標籤: '天氣'」所以我想我把inclusion_tag的聲明放在錯誤的地方?我需要把它放在哪裏才能得到它的工作?