これは私の以前の投稿です。テンプレートには、django ビュー/URL が含まれています。それらはどのように(する/すべきか)機能しますか?.
繰り返しますが、ミニボックスは正常に機能します。頂いたアドバイスを参考に、頑張ってみました。
だから私はprofile(request, profile_type, username)
見解を持っています。そこから「profile_intros」コンテキストを取得して、含まれている mini_profile.html テンプレートに配置しようとしています。
包含タグを作成しようとしました (サイト全体の他の場所で必要になるため):
@register.inclusion_tag('includes/profile_info.html', takes_context=True)(profile_info)
def profile_info(context):
profile_intros = FundRecommendation.objects.filter(investor=profile).count()
return{
'profile_intros' : context['profile_intros'],
}
{% profile_info %}
含まれている mini_profile.html テンプレートにスローします。私はdjango docの例に従ってきましたが、何が間違っているのか本当にわかりません。
私は得ています:
Exception Type: TemplateSyntaxError
Exception Value: Invalid block tag: 'profile_info'