瀏覽代碼

Refs #35591 -- Removed hardcoded "stable" version in runserver warning.

Mariusz Felisiak 7 月之前
父節點
當前提交
f883bef054
共有 4 個文件被更改,包括 16 次插入7 次删除
  1. 4 1
      django/core/management/commands/runserver.py
  2. 1 1
      docs/intro/tutorial01.txt
  3. 1 1
      docs/ref/django-admin.txt
  4. 10 4
      tests/admin_scripts/tests.py

+ 4 - 1
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/"
                 )
             )

+ 1 - 1
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

+ 1 - 1
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.
 

+ 10 - 4
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(),
         )