Friday, April 29, 2011

Re: Custom template tag -- Not registered?

On Fri, Apr 29, 2011 at 5:11 PM, Daniel Roseman <daniel@roseman.org.uk> wrote:
> On Friday, 29 April 2011 21:24:44 UTC+1, Kenny Meyer wrote:
>>
>> Hello,
>>
>> I have the following inclusion tag in templatetags/show_submissions.py :
>>
>> ## BOF
>>
>> register = template.Library()
>>
>> @register.inclusion_tag('competition/templatetags/show_submissions.html')
>> def show_submissions(participant):
>>     submissions = Submission.objects.get(participant=participant)
>>     return {"submissions": submissions}
>>
>> ## EOF
>>
>> Whenever Django reaches the following line in my templates:
>>
>>     {% show_submissions user.participant %}
>>
>> A TemplateSyntaxError gets raised, which I interpret as "I don't find
>> your templatetag". Here's the full traceback:
>> http://dpaste.com/537298/
>>
>> Observations:
>> * Restarted the dev server several times after registering the tag,
>> and got the same results.
>> * templatetags/ folder has a __init__.py
>> * Using Django 1.3
>>
>> Any ideas why I cannot use this inclusion tag?
>>
>> Kenny
>
> Your template doesn't seem to have {% load show_submissions %} anywhere.

Oh, I really forgot that... there was indeed no {% load
show_submissions %} anywhere.

Thanks for your kind help!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment