Preview Certificate error

I preview certificate show text

and log error

tutor_local-lms-1          | 2025-01-07 04:35:23,261 ERROR 23 [common.djangoapps.util.views] [user 2613] [ip xxxx] views.py:148 - Error in django view.
tutor_local-lms-1          | Traceback (most recent call last):
tutor_local-lms-1          |   File "/openedx/edx-platform/common/djangoapps/util/views.py", line 139, in inner
tutor_local-lms-1          |     return func(request, *args, **kwargs)
tutor_local-lms-1          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tutor_local-lms-1          |   File "/openedx/venv/lib/python3.11/site-packages/edx_django_utils/plugins/pluggable_override.py", line 77, in wrapper
tutor_local-lms-1          |     return prev_fn(*args, **kwargs)
tutor_local-lms-1          |            ^^^^^^^^^^^^^^^^^^^^^^^^
tutor_local-lms-1          |   File "/openedx/edx-platform/lms/djangoapps/certificates/views/webview.py", line 575, in render_html_view
tutor_local-lms-1          |     _update_certificate_context(context, course, course_overview, user_certificate, platform_name)
tutor_local-lms-1          |   File "/openedx/edx-platform/lms/djangoapps/certificates/views/webview.py", line 124, in _update_certificate_context
tutor_local-lms-1          |     context['certificate_date_issued'] = strftime_localized(date, settings.CERTIFICATE_DATE_FORMAT)
tutor_local-lms-1          |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tutor_local-lms-1          |   File "/openedx/edx-platform/common/djangoapps/util/date_utils.py", line 215, in strftime_localized
tutor_local-lms-1          |     formatted_date = re.sub(r"%-.|%.|%", process_percent_code, format)
tutor_local-lms-1          |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tutor_local-lms-1          |   File "/opt/pyenv/versions/3.11.8/lib/python3.11/re/__init__.py", line 185, in sub
tutor_local-lms-1          |     return _compile(pattern, flags).sub(repl, string, count)
tutor_local-lms-1          |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
tutor_local-lms-1          |   File "/openedx/edx-platform/common/djangoapps/util/date_utils.py", line 180, in process_percent_code
tutor_local-lms-1          |     part = pgettext('month name', MONTHS[dtime.month])
tutor_local-lms-1          |                                          ^^^^^^^^^^^
tutor_local-lms-1          | AttributeError: 'NoneType' object has no attribute 'month'

How to fix it.
I use tutor version 19(sumac)

At a quick glance, it seems like the issues occurs when trying to render the date of when certificate has been issued, because instead of date you get None, which can’t be formatted.

If you’re getting this error when trying to preview a certificate from the studio, based on this code, you might’ve misconfigured either certificate date override or course certificate available date.

I ran into this today with a fresh install and seem to have found that you must go into Schedule & Details and save that page (make a change if you have to in order to bring up the save button).
My Schedule & Details page was loading with the “Save” button immediately present, which makes me think that these courses are being initialized without some kind of critical date that the certificate requires.

When trying to recreate the error, I found that I further had to set the course to “Self-Paced” for the error to go away. After setting it to self-paced and confirming that the cert previews, I was able to go back to “Instructor Paced” and the cert still worked.

2 Likes

Hi John,
I’m facing a similar issue. It seems like this might be a bug on the Open edX side. When I access the Schedule & Details page, the “Save Changes” prompt appears even if no changes have been made, which could be related to the certificate issue. I’m also experiencing problems with the certificate preview in sumac release.
Regarding the suggestion to switch to “Self-Paced” mode — unfortunately, it looks like we can’t change the pacing once the course has already started.

@Abdul_Muqadim try set the start date of the course to a future date, therefore it will not have started yet and you should be able to switch the mode between self/instructor paced, following which you can revert the start date back

Thanks for the suggestion Joel,
The course we’re facing the issue with is quite old, and many students have already enrolled. I’m a bit concerned that changing the pacing type at this stage might alter some course configurations or affect existing enrollments. Do you think switching pacing could lead to any unintended changes?

I’m not aware of any such breakages which may result. I did a test on one of my old courses now changing from self to instructor and back to self, this did not affect existing enrolments or gradebooks. There may be something I’m not familiar with that is affected but from what I can tell this shouldn’t impact anything

1 Like