Thursday, July 28, 2011

Re: Problem With Templatetags

On Jul 28, 8:17 am, Showket Bhat <scorpion.sch...@gmail.com> wrote:
> Hi All,
>
> I am using templatetags to create one tag..

Actually (according to your code snippet) a filter.

> I created the folder
> templatetags and created 2 files in it.. __init__.py which is empty
> and another temp_tags.py.. where i put one method

s/method/function/

> temp_tags.py
> ====================
> from django import template
> register = template.Library()
> register.filter('lower', lower)
>
> def lower(value): # Only one argument.
> #       "Converts a string into all lowercase"
>         return value.lower()


If this is your exact real code, you should get a NameError on the
third line, where you try to register your filter function before it's
defined.


Also and FWIW, you don't really need such a filter, just use
{{ name.lower }} in your template.

> I ve not inserted anything in setting.py regarding templatetags and I
> am getting this error
>
> =============================
>
> TemplateSyntaxError at /view2/
>
> 'temp_tags' is not a valid tag library: Template library temp_tags not
> found, tried
> django.templatetags.temp_tags,django.contrib.admin.templatetags.temp_tags

The django app containing your templatetags package needs to be
registered in settings.INSTALLED_APPS.

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate