Forums

Problem with cutom tags in Django

Hello. This is tree of my app.

my_project/    
my_app/
    __init__.py
    models.py
    views.py
    templatetags/
        __init__.py
        blog_tags.py

When I trying to add a tag to base.html ({%load blog_tags %})gets an error

Exception Value:
'blog_tags' is not a valid tag library: ImportError raised loading blog.templatetags.blog_tags: No module named models

Exception Location:

/home/Aule/.virtualenvs/django18/local/lib/python2.7/site-packages/django/template/defaulttags.py in load, line 1163

I do not know what I'm doing wrong and I would ask for help.

Your app is in my_app, but your template loading is trying to load from blog

My_app was example. My app real name is blog.

Then it looks like you're trying to import the models module from the directory above and perhaps you're not referencing it correctly.

Thank you very much it was model :)