on 10 sep, 01:06, maroxe <bachir...@gmail.com> wrote: > Hi, I am suffering whereever i try to do something in django that is > not common(in django, not in python in general) > > For example, i don't know how to return an inclusion tag. This. > obviously, won't work: > > @register.inclusion_tag('template.tpl') > def myinclusiontag(parameter): > return {'var': parameter.attr1} > > @register.inclusion_tag('template2.tpl') > def myinclusiontag2(parameter): > return {'var': parameter.attr2} > > @register.simple_tag > def mysimpletag(paramter): > if parameter.attr: return myinclusiontag(parameter) > else: return myinclusiontag2(paramter) > > mysimpletag return a dict(first returned by the inclusion tag),
s/the inclusion tag/the function used to build the inclusion tag/ Reading the source code helps once again: register.inclusion_tag dynamically build the appropriate Node object and compiler function, calls register.tag with these, and returns the original function unchanged. There's surely a way to hack around this, but at this point I strongly suggest you learn to write a proper custom tag (Node and compiler func). It's by far easier than it seems at first and it's really something every Django developper should learn. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.