Answer the question
In order to leave comments, you need to log in
Django 4.0.3 Error: 'news_tags' is not a registered tag library. How to fix?
Friends, just don't beat with sticks, but I just can't figure out how to fix this error:
'news_tags' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz
I understand that this is a ridiculous question for experienced specialists, but I ask everyone to help.
Specific:
news/templates/templatags/news_tags.py
from django import template
from news.models import Category
register = template.Library()
@register.simple_tag
def get_categories():
return Category.objects.all()
{% load news_tags %} #ругается на эту часть
<div class="list-group">
{% get_categories as categories %}
{% for item in categories %}
<a href="{% url 'category' item.pk %}" class="list-group-item list-group-item-action">{{ item.title }}</a>
{% endfor %}
</div>
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question