1
0
mirror of https://github.com/django/django.git synced 2025-01-03 06:55:47 +00:00

Corrected code-block directives in docs.

This commit is contained in:
Mariusz Felisiak 2023-12-28 19:52:15 +01:00 committed by GitHub
parent ebf9320838
commit 0be6dde817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 17 deletions

View File

@ -252,7 +252,7 @@ model:
This command should produce the following output: This command should produce the following output:
.. console:: .. code-block:: sql
BEGIN; BEGIN;
-- --
@ -686,12 +686,13 @@ __ https://spatialreference.org/ref/epsg/32140/
.. code-block:: pycon .. code-block:: pycon
from django.db import connection >>> from django.db import connection
# or if you're querying a non-default database: >>> # or if you're querying a non-default database:
from django.db import connections >>> from django.db import connections
connection = connections['your_gis_db_alias'] >>> connection = connections["your_gis_db_alias"]
>>> City.objects.raw(
City.objects.raw('SELECT id, name, %s as point from myapp_city' % (connection.ops.select % 'point')) ... "SELECT id, name, %s as point from myapp_city" % (connection.ops.select % "point")
... )
You should only use raw queries when you know exactly what you're doing. You should only use raw queries when you know exactly what you're doing.

View File

@ -755,9 +755,7 @@ should avoid them if possible.
your SQL with user-provided data. your SQL with user-provided data.
You also must not quote placeholders in the SQL string. This example is You also must not quote placeholders in the SQL string. This example is
vulnerable to SQL injection because of the quotes around ``%s``: vulnerable to SQL injection because of the quotes around ``%s``::
.. code-block:: pycon
RawSQL("select col from sometable where othercol = '%s'") # unsafe! RawSQL("select col from sometable where othercol = '%s'") # unsafe!

View File

@ -1090,13 +1090,12 @@ Custom response classes
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
If you find yourself needing a response class that Django doesn't provide, you If you find yourself needing a response class that Django doesn't provide, you
can create it with the help of :py:class:`http.HTTPStatus`. For example: can create it with the help of :py:class:`http.HTTPStatus`. For example::
.. code-block:: pycon
from http import HTTPStatus from http import HTTPStatus
from django.http import HttpResponse from django.http import HttpResponse
class HttpResponseNoContent(HttpResponse): class HttpResponseNoContent(HttpResponse):
status_code = HTTPStatus.NO_CONTENT status_code = HTTPStatus.NO_CONTENT

View File

@ -519,11 +519,10 @@ Use of both ``and`` and ``or`` clauses within the same tag is allowed, with
{% if athlete_list and coach_list or cheerleader_list %} {% if athlete_list and coach_list or cheerleader_list %}
will be interpreted like: will be interpreted like::
.. code-block:: pycon if (athlete_list and coach_list) or cheerleader_list:
...
if (athlete_list and coach_list) or cheerleader_list
Use of actual parentheses in the :ttag:`if` tag is invalid syntax. If you need Use of actual parentheses in the :ttag:`if` tag is invalid syntax. If you need
them to indicate precedence, you should use nested :ttag:`if` tags. them to indicate precedence, you should use nested :ttag:`if` tags.