I did the calf's ear. forgive me for asking this stupid question.
*The error has been found, I try to load the function with my load when it's not the function that is loaded but the py file.
*update add directory tree
I'm in total misunderstanding, I created custom tags for my project. I had a hard time to get them accepted by django (I had to reboot my local server several times) finally it worked here I save a new custom tag, but I can't load it in django, it tells me that the tag doesn't exist. I restarted several times. I even made a copy of my previous code by simply changing the name of the function but I can't get django to take it, it tells me that it doesn't exist... Thank you in advance :)
in application > templatetags with init file etc...
in template use :
{% load tags_blog tags_files %}
work
{% load background_image %}
doesn't work The first two custom tags work
Work tag loaded in django :(base.html)
register = template.Library()
@register.simple_tag()
def news_archive_date_blog():
list_all_year = New.all_year_post()
if len(list_all_year) > 1:
list_all_year.remove(timezone.now().year)
return list_all_year
@register.simple_tag()
def rallies_archive_date_blog():
list_all_year = Rally.all_year_post()
if len(list_all_year) > 1:
list_all_year.remove(timezone.now().year)
return list_all_year
no work (TemplateSyntaxError at /'background_image' is not a registered tag library.)(base.html)
@register.simple_tag()
def background_image():
list_all_year = Rally.all_year_post()
if len(list_all_year) > 1:
list_all_year.remove(timezone.now().year)
return list_all_year
- bmvt:
- bmvt
- blog:
- templatetags
- init
- tags_blogs
- models
- templatetags
django.template.exceptions.TemplateSyntaxError django.template.exceptions.TemplateSyntaxError: 'backgroundimage' is not a registered tag library. Must be one of: account admin_list admin_modify admin_static admin_urls cache compress crispy_forms_field crispy_forms_filters crispy_forms_tags crispy_forms_utils debugger_tags highlighting hitcount_tags i18n indent_text l10n log pwa rest_framework socialaccount solo_tags static staticfiles syntax_color tags_blog tags_files truncate_letters tz widont
Traceback (most recent call last) File "/usr/local/lib/python3.7/site-packages/django/template/defaulttags.py", line 1021, in find_library return parser.libraries[name] During handling of the above exception, another exception occurred: File "/usr/local/lib/python3.7/site-packages/django/contrib/staticfiles/handlers.py", line 65, in call return self.application(environ, start_response) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 141, in call response = self.get_response(request) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 75, in get_response response = self._middleware_chain(request) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 36, in inner response = response_for_exception(request, exc) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info()) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File "/usr/local/lib/python3.7/site-packages/django_extensions/management/technical_response.py", line 37, in null_technical_500_response six.reraise(exc_type, exc_value, tb) File "/usr/local/lib/python3.7/site-packages/six.py", line 695, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 145, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 143, in _get_response response = response.render() File "/usr/local/lib/python3.7/site-packages/django/template/response.py", line 106, in render self.content = self.rendered_content File "/usr/local/lib/python3.7/site-packages/django/template/response.py", line 81, in rendered_content template = self.resolve_template(self.template_name) File "/usr/local/lib/python3.7/site-packages/django/template/response.py", line 63, in resolve_template return select_template(template, using=self.using) File "/usr/local/lib/python3.7/site-packages/django/template/loader.py", line 42, in select_template return engine.get_template(template_name) File "/usr/local/lib/python3.7/site-packages/django/template/backends/django.py", line 34, in get_template return Template(self.engine.get_template(template_name), self) File "/usr/local/lib/python3.7/site-packages/django/template/engine.py", line 143, in get_template template, origin = self.find_template(template_name) File "/usr/local/lib/python3.7/site-packages/django/template/engine.py", line 125, in find_template template = loader.get_template(name, skip=skip) File "/usr/local/lib/python3.7/site-packages/django/template/loaders/base.py", line 30, in get_template contents, origin, origin.template_name, self.engine, File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 156, in init self.nodelist = self.compile_nodelist() File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 194, in compile_nodelist return parser.parse() File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 478, in parse raise self.error(token, e) File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 476, in parse compiled_result = compile_func(self, token) File "/usr/local/lib/python3.7/site-packages/django/template/loader_tags.py", line 266, in do_extends nodelist = parser.parse() File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 478, in parse raise self.error(token, e) File "/usr/local/lib/python3.7/site-packages/django/template/base.py", line 476, in parse compiled_result = compile_func(self, token) File "/usr/local/lib/python3.7/site-packages/django/template/defaulttags.py", line 1078, in load lib = find_library(parser, name) File "/usr/local/lib/python3.7/site-packages/django/template/defaulttags.py", line 1025, in find_library name, "\n".join(sorted(parser.libraries)), django.template.exceptions.TemplateSyntaxError: 'backgroundimage' is not a registered tag library. Must be one of: account admin_list admin_modify admin_static admin_urls cache compress crispy_forms_field crispy_forms_filters crispy_forms_tags crispy_forms_utils debugger_tags highlighting hitcount_tags i18n indent_text l10n log pwa rest_framework socialaccount solo_tags static staticfiles syntax_color tags_blog tags_files truncate_letters tz widont
INSTALLED_APPS
, name of the files etc. Django works based on convention (rather then configuration), so file location and naming is essential. - RisadinhaINSTALLED_APPS = [ "bmvt.blog.apps.BlogConfig", "bmvt.files.apps.FilesConfig", "bmvt.agenda.apps.AgendaConfig", "bmvt.advertisement.apps.AdvertisementConfig"]
- Pascal de Sélys