zostera/django-bootstrap4

Missing templates folders in 23.3 release

Closed this issue · 5 comments

Hi,

When launching tests on my project, I realize that one of django-bootstrap4 teamplate is missing

Traceback (most recent call last):
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/base.py", line 170, in render
    return self._render(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/test/utils.py", line 100, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/base.py", line 938, in render
    bit = node.render_annotated(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/base.py", line 905, in render_annotated
    return self.render(context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/library.py", line 192, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/bootstrap4/templatetags/bootstrap4.py", line 823, in bootstrap_messages
    return render_template_file("bootstrap4/messages.html", context=context)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/bootstrap4/utils.py", line 114, in render_template_file
    template = get_template(template)
  File "/home/sandre35/.virtualenvs/subzero32/lib/python3.10/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: bootstrap4/messages.html

This issue only appears with the latest release : 23.3
Here is below the content of the django-bootstrap package. As you can see, the templates folder is missing.

(subzero32) sandre35@sandre35:~/.virtualenvs/subzero32/lib/python3.10/site-packages/bootstrap4$ ll
total 167
drwxrwxr-x   4 sandre35 sandre35    15 déc.  26 09:36 ./
drwxrwxr-x 518 sandre35 sandre35   555 déc.  26 09:36 ../
-rw-rw-r--   1 sandre35 sandre35    89 déc.  26 09:36 __about__.py
-rw-rw-r--   1 sandre35 sandre35  3633 déc.  26 09:36 bootstrap.py
-rw-rw-r--   1 sandre35 sandre35   900 déc.  26 09:36 components.py
-rw-rw-r--   1 sandre35 sandre35   166 déc.  26 09:36 exceptions.py
-rw-rw-r--   1 sandre35 sandre35  4738 déc.  26 09:36 forms.py
-rw-rw-r--   1 sandre35 sandre35    69 déc.  26 09:36 __init__.py
-rw-rw-r--   1 sandre35 sandre35    50 déc.  26 09:36 models.py
drwxrwxr-x   2 sandre35 sandre35    13 déc.  26 09:36 __pycache__/
-rw-rw-r--   1 sandre35 sandre35 21994 déc.  26 09:36 renderers.py
drwxrwxr-x   3 sandre35 sandre35     5 déc.  26 09:36 templatetags/
-rw-rw-r--   1 sandre35 sandre35   467 déc.  26 09:36 text.py
-rw-rw-r--   1 sandre35 sandre35  4680 déc.  26 09:36 utils.py
-rw-rw-r--   1 sandre35 sandre35   301 déc.  26 09:36 widgets.py
(subzero32) sandre35@sandre35:~/.virtualenvs/subzero32/lib/python3.10/site-packages/bootstrap4$ pip show django-bootstrap4
Name: django-bootstrap4
Version: 23.3
Summary: Django extensions by Zostera
[...]

Regards,

Templates is where you begin setting up your basic HTML CSS JS for your project. Therefore, you need to create a templates folder and put HTML in it to be taken from your DJANGO to the front end. Maybe this will help:
https://docs.djangoproject.com/en/3.0/ref/templates/language/.

Hi @pythonyalfa

Sure I perfectly agree with your point about templates being used in the front end. However, my point is particularly focused on templates that are provided by django-bootstrap4 package. Since HTML files are not provided in the django-bootstrap4 23.3 build, they can not be localized by Django.

In my example, the missing template is bootstrap/message.html

That's what I mean. It seems your are missing the templates folder, and the message.html file inside the template folder which you are supposed to create yourself and then import the Django bootstrap tags. Here is a pic of what I think you're missing in your project. I'm still learning both Django and bootstrap so sorry if I'm confusing you or if I'm wrong, but but this I how I have come to understand Django templates.

Screenshot_20231226-040804.png

I think you are missing one point. You are not restricted to templates of your own project. You can use templates declared in dependencies of your project, if you declare corresponding apps in your INSTALLED_APPS

See https://docs.djangoproject.com/en/5.0/topics/templates/#configuration

I'm encountering the same issue as of upgrading to 23.3. I had to pin 23.2 to workaround this for now:
Exception Type: TemplateDoesNotExist
Exception Value: bootstrap4/messages.html