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 opinion:

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

      

my html:

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

      

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

why??

thanks

updated

but when i set this to c.html:

{% load helloworld_tags%} 

      

and change the view:

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

      

and b.html:

 dsad {{ eee }}

      

now nothing is displayed,

why?

thanks

updated2

now it's ok when i add this to c.html:

{% load helloworld_tags%} 
{% show_profile %}

      

+2


a source to share


1 answer


This may not work. You need one template for rendering the view and another template for the include template. You can't use the same pattern for both uses, it just doesn't make any sense.



+2


a source







All Articles