From f883bef05457a5a49eb31109429fc01737f82532 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Sun, 11 Aug 2024 13:08:00 +0200 Subject: [PATCH] Refs #35591 -- Removed hardcoded "stable" version in runserver warning. --- django/core/management/commands/runserver.py | 5 ++++- docs/intro/tutorial01.txt | 2 +- docs/ref/django-admin.txt | 2 +- tests/admin_scripts/tests.py | 14 ++++++++++---- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py index 3795809a122..2c8e445de86 100644 --- a/django/core/management/commands/runserver.py +++ b/django/core/management/commands/runserver.py @@ -11,6 +11,7 @@ from django.core.servers.basehttp import WSGIServer, get_internal_wsgi_applicati from django.db import connections from django.utils import autoreload from django.utils.regex_helper import _lazy_re_compile +from django.utils.version import get_docs_version naiveip_re = _lazy_re_compile( r"""^(?: @@ -188,12 +189,14 @@ class Command(BaseCommand): f"Quit the server with {quit_command}.", file=self.stdout, ) + docs_version = get_docs_version() if os.environ.get("HIDE_PRODUCTION_WARNING") != "true": self.stdout.write( self.style.WARNING( "WARNING: This is a development server. Do not use it in a " "production setting. Use a production WSGI or ASGI server " "instead.\nFor more information on production servers see: " - "https://docs.djangoproject.com/en/stable/howto/deployment/" + f"https://docs.djangoproject.com/en/{docs_version}/howto/" + "deployment/" ) ) diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt index 0536eca2f77..3f89220949d 100644 --- a/docs/intro/tutorial01.txt +++ b/docs/intro/tutorial01.txt @@ -135,7 +135,7 @@ You'll see the following output on the command line: Quit the server with CONTROL-C. WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead. - For more information on production servers see: https://docs.djangoproject.com/en/stable/howto/deployment/ + For more information on production servers see: https://docs.djangoproject.com/en/|version|/howto/deployment/ .. note:: Ignore the warning about unapplied database migrations for now; we'll deal diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 52eaaa331b6..f2c9e1bdc35 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -957,7 +957,7 @@ suitable for production: .. code-block:: text WARNING: This is a development server. Do not use it in a production setting. Use a production WSGI or ASGI server instead. - For more information on production servers see: https://docs.djangoproject.com/en/stable/howto/deployment/ + For more information on production servers see: https://docs.djangoproject.com/en/|version|/howto/deployment/ Set this environment variable to ``"true"`` to hide this warning. diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py index 67362460a99..5ee3eeb8033 100644 --- a/tests/admin_scripts/tests.py +++ b/tests/admin_scripts/tests.py @@ -33,7 +33,7 @@ from django.db.migrations.recorder import MigrationRecorder from django.test import LiveServerTestCase, SimpleTestCase, TestCase, override_settings from django.test.utils import captured_stderr, captured_stdout from django.urls import path -from django.utils.version import PY313 +from django.utils.version import PY313, get_docs_version from django.views.static import serve from . import urls @@ -1597,11 +1597,13 @@ class ManageRunserver(SimpleTestCase): "Starting development server at http://0.0.0.0:8000/", self.output.getvalue(), ) + docs_version = get_docs_version() self.assertIn( "WARNING: This is a development server. Do not use it in a " "production setting. Use a production WSGI or ASGI server instead." "\nFor more information on production servers see: " - "https://docs.djangoproject.com/en/stable/howto/deployment/", + f"https://docs.djangoproject.com/en/{docs_version}/howto/" + "deployment/", self.output.getvalue(), ) @@ -1613,11 +1615,13 @@ class ManageRunserver(SimpleTestCase): "Starting development server at http://127.0.0.1:14437/", self.output.getvalue(), ) + docs_version = get_docs_version() self.assertIn( "WARNING: This is a development server. Do not use it in a " "production setting. Use a production WSGI or ASGI server instead." "\nFor more information on production servers see: " - "https://docs.djangoproject.com/en/stable/howto/deployment/", + f"https://docs.djangoproject.com/en/{docs_version}/howto/" + "deployment/", self.output.getvalue(), ) @@ -1630,11 +1634,13 @@ class ManageRunserver(SimpleTestCase): "Starting development server at http://0.0.0.0:8000/", self.output.getvalue(), ) + docs_version = get_docs_version() self.assertNotIn( "WARNING: This is a development server. Do not use it in a " "production setting. Use a production WSGI or ASGI server instead." "\nFor more information on production servers see: " - "https://docs.djangoproject.com/en/stable/howto/deployment/", + f"https://docs.djangoproject.com/en/{docs_version}/howto/" + "deployment/", self.output.getvalue(), )