Certificate template doesn't work

I have a certificate template registered in Django, when it is active, an error appears when generating the certificate (https://us1.discourse-cdn.com/flex020/uploads/openedx/original/2X/6/6f4588ec74369174ad33623805c382dab28c7e09.png) , if I disable the certificate template, a standard certificate is generated. Tell me, what could be the matter?

If I remove this fragment with the print button from the template, the certificate is generated normally. I have a tutor 19.

  •   <div>*
    
  •   <font color="#000000" </font>*
    
  •   	<h2>${accomplishment_banner_opening}</h2>*
    
  •   	<p class="message-copy copy copy-base emphasized">${accomplishment_banner_congrats}</p>*
    
  •   	<div class="message-actions">*
    
  •   		<button class="inverse" id="action-print-view">*
    
  •   			${_("Print Certificate")}*
    
  •   		</button>*
    
  •   	</div>*
    
  •   </font>*
    
  •   </div>*
    
*

Hi @guren1290, welcome to the community!
Please check the logs in the LMS, this will give you a hint of what is wrong in the template.

Thank you for responding to my question. Please help me figure it out, I’m new to this

:warning: You are running Tutor as root. This is strongly not recommended. If you are doing this in order to access the Docker daemon, you should instead add your user to the ‘docker’ group. (see Post-installation steps | Docker Docs)
docker compose -f /root/.local/share/tutor/env/local/docker-compose.yml -f /root/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local logs --follow --tail 100 lms
lms-1 | File “/openedx/edx-platform/openedx/core/djangoapps/theming/helpers.py”, line 242, in get_theme_base_dir
lms-1 | raise ValueError(
lms-1 | ValueError: Theme ‘branded’ not found in any of the following themes dirs,
lms-1 | Theme dirs:
lms-1 | [Path(‘/openedx/themes’)]
lms-1 | 2025-01-31 04:12:48,986 ERROR 23 [openedx.core.djangoapps.theming.helpers] [user 5] [ip 192.168.159.238] helpers.py:209 - Theme not found in any of the themes dirs. [Theme ‘branded’ not found in any of the following themes dirs,
lms-1 | Theme dirs:
lms-1 | [Path(‘/openedx/themes’)]]
lms-1 | Traceback (most recent call last):
lms-1 | File “/openedx/edx-platform/common/djangoapps/util/views.py”, line 139, in inner
lms-1 | return func(request, *args, **kwargs)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/edx_django_utils/plugins/pluggable_override.py”, line 77, in wrapper
lms-1 | return prev_fn(*args, **kwargs)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/lms/djangoapps/certificates/views/webview.py”, line 607, in render_html_view
lms-1 | response = _render_valid_certificate(request, context, custom_template)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/lms/djangoapps/certificates/views/webview.py”, line 695, in _render_valid_certificate
lms-1 | return HttpResponse(template.render(context))
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/common/djangoapps/edxmako/template.py”, line 82, in render
lms-1 | return self.mako_template.render_unicode(**context_dictionary)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/template.py”, line 443, in render_unicode
lms-1 | return runtime._render(
lms-1 | ^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 874, in _render
lms-1 | _render_context(
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 916, in _render_context
lms-1 | _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 943, in exec_template
lms-1 | callable
(context, *args, **kwargs)
lms-1 | File “memory:0x7b723c97f650”, line 47, in render_body
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/filters.py”, line 47, in decode
lms-1 | return decode(str(x))
lms-1 | ^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 230, in str
lms-1 | raise NameError(“Undefined”)
lms-1 | NameError: Undefined
lms-1 |
lms-1 | During handling of the above exception, another exception occurred:
lms-1 |
lms-1 | Traceback (most recent call last):
lms-1 | File “/openedx/edx-platform/openedx/core/djangoapps/theming/helpers.py”, line 204, in get_current_theme
lms-1 | themes_base_dir=get_theme_base_dir(site_theme.theme_dir_name),
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/openedx/core/djangoapps/theming/helpers.py”, line 242, in get_theme_base_dir
lms-1 | raise ValueError(
lms-1 | ValueError: Theme ‘branded’ not found in any of the following themes dirs,
lms-1 | Theme dirs:
lms-1 | [Path(‘/openedx/themes’)]
lms-1 | 2025-01-31 04:12:48,989 ERROR 23 [openedx.core.djangoapps.theming.helpers] [user 5] [ip 192.168.159.238] helpers.py:209 - Theme not found in any of the themes dirs. [Theme ‘branded’ not found in any of the following themes dirs,
lms-1 | Theme dirs:
lms-1 | [Path(‘/openedx/themes’)]]
lms-1 | Traceback (most recent call last):
lms-1 | File “/openedx/edx-platform/common/djangoapps/util/views.py”, line 139, in inner
lms-1 | return func(request, *args, **kwargs)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/edx_django_utils/plugins/pluggable_override.py”, line 77, in wrapper
lms-1 | return prev_fn(*args, **kwargs)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/lms/djangoapps/certificates/views/webview.py”, line 607, in render_html_view
lms-1 | response = _render_valid_certificate(request, context, custom_template)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/lms/djangoapps/certificates/views/webview.py”, line 695, in _render_valid_certificate
lms-1 | return HttpResponse(template.render(context))
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/common/djangoapps/edxmako/template.py”, line 82, in render
lms-1 | return self.mako_template.render_unicode(**context_dictionary)
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/template.py”, line 443, in render_unicode
lms-1 | return runtime._render(
lms-1 | ^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 874, in _render
lms-1 | _render_context(
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 916, in _render_context
lms-1 | _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 943, in exec_template
lms-1 | callable
(context, *args, **kwargs)
lms-1 | File “memory:0x7b723c97f650”, line 47, in render_body
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/filters.py”, line 47, in decode
lms-1 | return decode(str(x))
lms-1 | ^^^^^^
lms-1 | File “/openedx/venv/lib/python3.11/site-packages/mako/runtime.py”, line 230, in str
lms-1 | raise NameError(“Undefined”)
lms-1 | NameError: Undefined
lms-1 |
lms-1 | During handling of the above exception, another exception occurred:
lms-1 |
lms-1 | Traceback (most recent call last):
lms-1 | File “/openedx/edx-platform/openedx/core/djangoapps/theming/helpers.py”, line 204, in get_current_theme
lms-1 | themes_base_dir=get_theme_base_dir(site_theme.theme_dir_name),
lms-1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lms-1 | File “/openedx/edx-platform/openedx/core/djangoapps/theming/helpers.py”, line 242, in get_theme_base_dir
lms-1 | raise ValueError(
lms-1 | ValueError: Theme ‘branded’ not found in any of the following themes dirs,
lms-1 | Theme dirs:
lms-1 | [Path(‘/openedx/themes’)]
lms-1 | [pid: 23|app: 0|req: 161/388] 192.168.101.4 () {46 vars in 3159 bytes} [Fri Jan 31 04:12:48 2025] GET /certificates/course/course-v1:kursy_pok+1+1?preview=honor => generated 9871 bytes in 485 msecs (HTTP/1.1 200) 8 headers in 477 bytes (1 switches on core 0)

Hello @guren1290

I’m pretty sure the problem is “${_(“Print Certificate”)}*” but if you want you can use this template:

cert_template.txt (7.1 KB)

Also make sure the course start and end dates are set correctly if your course pace is set to “Instructor Pace” (in my experience I recommend using “self-paced” and enabling certificate auto-generation).

good luck,
rax

Thank you, you helped me a lot

1 Like