开发者

some register.inclusion_tag error in my code using django

开发者 https://www.devze.com 2022-12-27 23:16 出处:网络
my helloworld_tags: from django import template register = template.Library() def show_profile(): return {\"eee\": \'333\'}

my helloworld_tags:

from django import template

register = template.Library()

def show_profile():
    return {"eee": '333'}
register.inclusion_tag("b.html")(show_profile)

my view:

def b(request):
    return render_to_response('b.html')

my html:

{% load helloworld_tags%} 
 dsad {{ eee }}

but only show 'dsad' ,not show 'dsad333'

why??

thanks

updated

but when i set this in c.html:

{% load helloworld_tags%} 

and change the view:

def b(request):
    return render_to_res开发者_Python百科ponse('c.html')

and the b.html is:

 dsad {{ eee }}

it is show nothing now ,

why ?

thanks

updated2

it is ok now ,when i add this to c.html:

{% load helloworld_tags%} 
{% show_profile %}


This can't possibly work. You need one template for the view to render, and another different template for the inclusion template. You can't use the same template for both uses, it simply doesn't make any sense.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号