TemplateSyntaxError: inlines is not a valid tag library
-
28-06-2021 - |
Question
Building my Django app, I have been using some code from django-basic-app, in particular the inlines
application.
In my blog
app, I load inlines
in a template (here in blog/templates/admin/blog/change_form.html
)
{% extends "admin/change_form.html" %}
{% block extrahead %}
{% load adminmedia inlines %}
{{ block.super }}
When I do that, I have an error
TemplateSyntaxError at /admin/blog/post/1/
'inlines' is not a valid tag library: ImportError raised loading inlines.templatetags.inlines: No module named models
The structure of the project is
blog/
templates/admin/blog/
change_form.html
...
inlines/
__init__.py
models.py
templatetags/
__init__.py
inlines.py
...
and with the import in inlines/templatetags/inlines.py
from django import template
from inlines.models import InlineType
from inlines.parser import inlines
import re
inlines
is present in INSTALLED_APPS
and I am using Django 1.4 with python 2.7
I am trying to have a standalone application (not linked to the project then) but I don't get why it is not detected by the blog app. The inlines models are detected by django, I am able to manage it using the admin interface, just the templatetags is failing.
Solution
Try to rename inlines.py
module to inlines_tags.py
for example, so a module and a package will not be same named. And dont forget to remove all old *.pyc
files from templatetags folder