From 9e13d89baaf7c137f0fc94f155e801a4642e5e0d Mon Sep 17 00:00:00 2001 From: Jason Novinger Date: Fri, 14 Nov 2025 16:24:17 -0600 Subject: [PATCH] Fixes #20766: Prevent translation of code/commands in error templates Use blocktrans 'with' clause to pass literal code/commands as variables, preventing them from being translated. This fixes issues where commands like 'manage.py collectstatic' were incorrectly translated to nonsensical strings in non-English locales. Updated templates: - media_failure.html: manage.py collectstatic - programming_error.html: python3 manage.py migrate, SELECT VERSION() - import_error.html: requirements.txt, local_requirements.txt, pip freeze --- netbox/templates/exceptions/import_error.html | 6 +++--- netbox/templates/exceptions/programming_error.html | 8 ++++---- netbox/templates/media_failure.html | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/netbox/templates/exceptions/import_error.html b/netbox/templates/exceptions/import_error.html index 1996412e1dd..595a7eb52ca 100644 --- a/netbox/templates/exceptions/import_error.html +++ b/netbox/templates/exceptions/import_error.html @@ -8,10 +8,10 @@

{% trans "Missing required packages" %}. - {% blocktrans trimmed %} + {% blocktrans trimmed with req_file="requirements.txt" local_req_file="local_requirements.txt" pip_cmd="pip freeze" %} This installation of NetBox might be missing one or more required Python packages. These packages are listed in - requirements.txt and local_requirements.txt, and are normally installed as part of the - installation or upgrade process. To verify installed packages, run pip freeze from the console and + {{ req_file }} and {{ local_req_file }}, and are normally installed as part of the + installation or upgrade process. To verify installed packages, run {{ pip_cmd }} from the console and compare the output to the list of required packages. {% endblocktrans %}

diff --git a/netbox/templates/exceptions/programming_error.html b/netbox/templates/exceptions/programming_error.html index e5275a31726..3cf9e2cd0fe 100644 --- a/netbox/templates/exceptions/programming_error.html +++ b/netbox/templates/exceptions/programming_error.html @@ -8,17 +8,17 @@

{% trans "Database migrations missing" %}. - {% blocktrans trimmed %} + {% blocktrans trimmed with command="python3 manage.py migrate" %} When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You - can run migrations manually by executing python3 manage.py migrate from the command line. + can run migrations manually by executing {{ command }} from the command line. {% endblocktrans %}

{% trans "Unsupported PostgreSQL version" %}. - {% blocktrans trimmed %} + {% blocktrans trimmed with sql_query="SELECT VERSION()" %} Ensure that PostgreSQL version 14 or later is in use. You can check this by connecting to the database using - NetBox's credentials and issuing a query for SELECT VERSION(). + NetBox's credentials and issuing a query for {{ sql_query }}. {% endblocktrans %}

{% endblock message %} diff --git a/netbox/templates/media_failure.html b/netbox/templates/media_failure.html index 8f357aea177..348a0297026 100644 --- a/netbox/templates/media_failure.html +++ b/netbox/templates/media_failure.html @@ -26,8 +26,8 @@

{% trans "Check the following" %}: