On 2013-08-20, at 3:53 AM, kandelabr <kandel...@gmail.com> wrote:

> Hello!
> 
> I want to define a new template tag and use it in a number of applications 
> inside my django project. The documentation says:
> 
> Custom template tags and filters must live inside a Django app. If they 
> relate to an existing app it makes sense to bundle them there; otherwise, you 
> should create a new app to hold them.
> 
> But I could not find a word in documentation on how to {% load %} tags from 
> another app. I added the new 'custom_tags' app it to INSTALLED_APPS, 
> registered, imported the tag, restarted the server, etc., but I couldn't get 
> past the error page: 
> 
> 'custom_tags' is not a valid tag library: Template library custom_tags not 
> found, tried 
> django.templatetags.custom_tags,django.contrib.staticfiles.templatetags.custom_tags,django.contrib.admin.templatetags.custom_tags
> 
> Could someone please explain where to put my custom tags so that I will be 
> able to reuse them throughout the project?

You have not explained exactly where you put your "custom_tags" app. Check the 
following things:

o The custom_tags/ directory should be in the same directory as your manage.py
o Your template tag(s) should be in, say, 
custom_tags/templatetags/custom_tags.py
o There should be two empty files, custom_tags/__init__.py and 
custom_tags/template_tags/__init__.py
o Use "{% load custom_tags %}" where the "custom_tags" here refers to the file 
name, not the app name

I'm guessing you have most of this but are missing the __init__.py files.

hth

                  - Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to