开发者

some register.inclusion_tag error in my code using django

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜