diff --git a/.github/workflows/schedule_tests.yml b/.github/workflows/schedule_tests.yml index 78b06ba5de..2cf62493c3 100644 --- a/.github/workflows/schedule_tests.yml +++ b/.github/workflows/schedule_tests.yml @@ -200,10 +200,10 @@ jobs: strategy: fail-fast: false matrix: - version: [16, 17rc1] + version: [16, 17] server_side_bindings: [0, 1] runs-on: ubuntu-latest - name: Newer PostgreSQL Versions + name: PostgreSQL Versions env: SERVER_SIDE_BINDING: ${{ matrix.server_side_bindings }} services: diff --git a/django/conf/project_template/project_name/settings.py-tpl b/django/conf/project_template/project_name/settings.py-tpl index 3b6caab333..5631ec9a31 100644 --- a/django/conf/project_template/project_name/settings.py-tpl +++ b/django/conf/project_template/project_name/settings.py-tpl @@ -58,7 +58,6 @@ TEMPLATES = [ 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ - 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt index 3f89220949..d45fa6bcb6 100644 --- a/docs/intro/tutorial01.txt +++ b/docs/intro/tutorial01.txt @@ -275,6 +275,8 @@ include the URLconf defined in ``polls.urls``. To do this, add an import for path("admin/", admin.site.urls), ] +The :func:`~django.urls.path` function expects at least two arguments: +``route`` and ``view``. The :func:`~django.urls.include` function allows referencing other URLconfs. Whenever Django encounters :func:`~django.urls.include`, it chops off whatever part of the URL matched up to that point and sends the remaining string to the @@ -307,45 +309,6 @@ text "*Hello, world. You're at the polls index.*", which you defined in the If you get an error page here, check that you're going to http://localhost:8000/polls/ and not http://localhost:8000/. -The :func:`~django.urls.path` function is passed four arguments, two required: -``route`` and ``view``, and two optional: ``kwargs``, and ``name``. -At this point, it's worth reviewing what these arguments are for. - -:func:`~django.urls.path` argument: ``route`` ---------------------------------------------- - -``route`` is a string that contains a URL pattern. When processing a request, -Django starts at the first pattern in ``urlpatterns`` and makes its way down -the list, comparing the requested URL against each pattern until it finds one -that matches. - -Patterns don't search GET and POST parameters, or the domain name. For example, -in a request to ``https://www.example.com/myapp/``, the URLconf will look for -``myapp/``. In a request to ``https://www.example.com/myapp/?page=3``, the -URLconf will also look for ``myapp/``. - -:func:`~django.urls.path` argument: ``view`` --------------------------------------------- - -When Django finds a matching pattern, it calls the specified view function with -an :class:`~django.http.HttpRequest` object as the first argument and any -"captured" values from the route as keyword arguments. We'll give an example -of this in a bit. - -:func:`~django.urls.path` argument: ``kwargs`` ----------------------------------------------- - -Arbitrary keyword arguments can be passed in a dictionary to the target view. We -aren't going to use this feature of Django in the tutorial. - -:func:`~django.urls.path` argument: ``name`` --------------------------------------------- - -Naming your URL lets you refer to it unambiguously from elsewhere in Django, -especially from within templates. This powerful feature allows you to make -global changes to the URL patterns of your project while only touching a single -file. - When you're comfortable with the basic request and response flow, read :doc:`part 2 of this tutorial ` to start working with the database. diff --git a/docs/intro/tutorial07.txt b/docs/intro/tutorial07.txt index e0c87be898..60a5c43bb3 100644 --- a/docs/intro/tutorial07.txt +++ b/docs/intro/tutorial07.txt @@ -324,7 +324,6 @@ Open your settings file (:file:`mysite/settings.py`, remember) and add a "APP_DIRS": True, "OPTIONS": { "context_processors": [ - "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", diff --git a/docs/ref/middleware.txt b/docs/ref/middleware.txt index 4aab186c8b..b5534ce8f6 100644 --- a/docs/ref/middleware.txt +++ b/docs/ref/middleware.txt @@ -34,6 +34,12 @@ defines. See the :doc:`cache documentation `. .. class:: CommonMiddleware + .. attribute:: response_redirect_class + + Defaults to :class:`~django.http.HttpResponsePermanentRedirect`. Subclass + ``CommonMiddleware`` and override the attribute to customize the redirects + issued by the middleware. + Adds a few conveniences for perfectionists: * Forbids access to user agents in the :setting:`DISALLOWED_USER_AGENTS` @@ -75,12 +81,6 @@ Adds a few conveniences for perfectionists: * Sets the ``Content-Length`` header for non-streaming responses. -.. attribute:: CommonMiddleware.response_redirect_class - -Defaults to :class:`~django.http.HttpResponsePermanentRedirect`. Subclass -``CommonMiddleware`` and override the attribute to customize the redirects -issued by the middleware. - .. class:: BrokenLinkEmailsMiddleware * Sends broken link notification emails to :setting:`MANAGERS` (see @@ -164,16 +164,16 @@ Locale middleware .. class:: LocaleMiddleware + .. attribute:: LocaleMiddleware.response_redirect_class + + Defaults to :class:`~django.http.HttpResponseRedirect`. Subclass + ``LocaleMiddleware`` and override the attribute to customize the + redirects issued by the middleware. + Enables language selection based on data from the request. It customizes content for each user. See the :doc:`internationalization documentation `. -.. attribute:: LocaleMiddleware.response_redirect_class - -Defaults to :class:`~django.http.HttpResponseRedirect`. Subclass -``LocaleMiddleware`` and override the attribute to customize the redirects -issued by the middleware. - Message middleware ------------------ @@ -500,6 +500,29 @@ every incoming ``HttpRequest`` object. See :ref:`Authentication in web requests .. class:: LoginRequiredMiddleware + Subclass the middleware and override the following attributes and methods + to customize behavior for unauthenticated requests. + + .. attribute:: redirect_field_name + + Defaults to ``"next"``. + + .. method:: get_login_url() + + Returns the URL that unauthenticated requests will be redirected to. This + result is either the ``login_url`` set on the + :func:`~django.contrib.auth.decorators.login_required` decorator (if not + ``None``), or :setting:`settings.LOGIN_URL `. + + .. method:: get_redirect_field_name() + + Returns the name of the query parameter that contains the URL the user + should be redirected to after a successful login. This result is either + the ``redirect_field_name`` set on the + :func:`~.django.contrib.auth.decorators.login_required` decorator (if not + ``None``), or :attr:`redirect_field_name`. If ``None`` is returned, a query + parameter won't be added. + .. versionadded:: 5.1 Redirects all unauthenticated requests to a login page, except for views @@ -552,31 +575,6 @@ Customize the login URL or field name for authenticated views with the :ref:`enabled unauthenticated requests ` to your login view. -**Methods and Attributes** - -Subclass the middleware and override these to customize behavior for -unauthenticated requests. - -.. attribute:: redirect_field_name - - Defaults to ``"next"``. - -.. method:: get_login_url() - - Returns the URL that unauthenticated requests will be redirected to. If - defined, this returns the ``login_url`` set on the - :func:`~.django.contrib.auth.decorators.login_required` decorator. Defaults - to :setting:`settings.LOGIN_URL `. - -.. method:: get_redirect_field_name() - - Returns the name of the query parameter that contains the URL the user - should be redirected to after a successful login. If defined, this returns - the ``redirect_field_name`` set on the - :func:`~.django.contrib.auth.decorators.login_required` decorator. Defaults - to :attr:`redirect_field_name`. If ``None`` is returned, a query parameter - won't be added. - .. class:: RemoteUserMiddleware Middleware for utilizing web server provided authentication. See diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index a46717b8d7..8d5c66367d 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -660,7 +660,6 @@ settings file, the default template engine contains the following context processors:: [ - "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", diff --git a/docs/ref/urls.txt b/docs/ref/urls.txt index 2ef873d348..95eb03f35a 100644 --- a/docs/ref/urls.txt +++ b/docs/ref/urls.txt @@ -25,6 +25,9 @@ Returns an element for inclusion in ``urlpatterns``. For example:: ..., ] +``route`` +--------- + The ``route`` argument should be a string or :func:`~django.utils.translation.gettext_lazy()` (see :ref:`translating-urlpatterns`) that contains a URL pattern. The string @@ -33,16 +36,43 @@ URL and send it as a keyword argument to the view. The angle brackets may include a converter specification (like the ``int`` part of ````) which limits the characters matched and may also change the type of the variable passed to the view. For example, ```` matches a string -of decimal digits and converts the value to an ``int``. See +of decimal digits and converts the value to an ``int``. + +When processing a request, Django starts at the first pattern in +``urlpatterns`` and makes its way down the list, comparing the requested URL +against each pattern until it finds one that matches. See :ref:`how-django-processes-a-request` for more details. +Patterns don't match GET and POST parameters, or the domain name. For example, +in a request to ``https://www.example.com/myapp/``, the URLconf will look for +``myapp/``. In a request to ``https://www.example.com/myapp/?page=3``, the +URLconf will also look for ``myapp/``. + +``view`` +-------- + The ``view`` argument is a view function or the result of :meth:`~django.views.generic.base.View.as_view` for class-based views. It can -also be an :func:`django.urls.include`. +also be a :func:`django.urls.include`. + +When Django finds a matching pattern, it calls the specified view function with +an :class:`~django.http.HttpRequest` object as the first argument and any +"captured" values from the route as keyword arguments. + +``kwargs`` +---------- The ``kwargs`` argument allows you to pass additional arguments to the view function or method. See :ref:`views-extra-options` for an example. +``name`` +-------- + +Naming your URL lets you refer to it unambiguously from elsewhere in Django, +especially from within templates. This powerful feature allows you to make +global changes to the URL patterns of your project while only touching a single +file. + See :ref:`Naming URL patterns ` for why the ``name`` argument is useful. diff --git a/docs/releases/5.2.txt b/docs/releases/5.2.txt index 14ad32b706..c445e02694 100644 --- a/docs/releases/5.2.txt +++ b/docs/releases/5.2.txt @@ -328,6 +328,9 @@ Miscellaneous * ``HttpRequest.accepted_types`` is now sorted by the client's preference, based on the request's ``Accept`` header. +* The :func:`~django.template.context_processors.debug` context processor is no + longer included in the default project template. + .. _deprecated-features-5.2: Features deprecated in 5.2 diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index fc1bb86d85..16d76f5da2 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1686,7 +1686,6 @@ class AdminViewBasicTest(AdminViewBasicTestCase): "APP_DIRS": True, "OPTIONS": { "context_processors": [ - "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", @@ -7695,7 +7694,6 @@ class AdminDocsTest(TestCase): "APP_DIRS": True, "OPTIONS": { "context_processors": [ - "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", diff --git a/tests/runtests.py b/tests/runtests.py index c5bb637d33..516da84768 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -221,7 +221,6 @@ def setup_collect_tests(start_at, start_after, test_labels=None): "APP_DIRS": True, "OPTIONS": { "context_processors": [ - "django.template.context_processors.debug", "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages",