mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[4.2.x] Refs #34140 -- Applied rst code-block to non-Python examples.
Thanks to J.V. Zammit, Paolo Melchiorre, and Mariusz Felisiak for
reviews.
Backport of 534ac48297 from main.
This commit is contained in:
committed by
Mariusz Felisiak
parent
4a89aa25c9
commit
b784768eef
@@ -195,7 +195,9 @@ It's difficult to give an official citation format, for two reasons: citation
|
||||
formats can vary wildly between publications, and citation standards for
|
||||
software are still a matter of some debate.
|
||||
|
||||
For example, `APA style`_, would dictate something like::
|
||||
For example, `APA style`_, would dictate something like:
|
||||
|
||||
.. code-block:: text
|
||||
|
||||
Django (Version 1.5) [Computer Software]. (2013). Retrieved from https://www.djangoproject.com/.
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ How can I see the raw SQL queries Django is running?
|
||||
====================================================
|
||||
|
||||
Make sure your Django :setting:`DEBUG` setting is set to ``True``.
|
||||
Then do this::
|
||||
Then do this:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from django.db import connection
|
||||
>>> connection.queries
|
||||
@@ -17,16 +19,18 @@ Then do this::
|
||||
|
||||
``connection.queries`` is only available if :setting:`DEBUG` is ``True``.
|
||||
It's a list of dictionaries in order of query execution. Each dictionary has
|
||||
the following::
|
||||
the following:
|
||||
|
||||
``sql`` -- The raw SQL statement
|
||||
``time`` -- How long the statement took to execute, in seconds.
|
||||
* ``sql`` - The raw SQL statement
|
||||
* ``time`` - How long the statement took to execute, in seconds.
|
||||
|
||||
``connection.queries`` includes all SQL statements -- INSERTs, UPDATES,
|
||||
SELECTs, etc. Each time your app hits the database, the query will be recorded.
|
||||
|
||||
If you are using :doc:`multiple databases</topics/db/multi-db>`, you can use the
|
||||
same interface on each member of the ``connections`` dictionary::
|
||||
same interface on each member of the ``connections`` dictionary:
|
||||
|
||||
.. code-block:: pycon
|
||||
|
||||
>>> from django.db import connections
|
||||
>>> connections['my_db_alias'].queries
|
||||
@@ -85,6 +89,8 @@ these options, create a migration with a
|
||||
``ALTER TABLE`` statements that do what you want to do.
|
||||
|
||||
For example, if you're using MySQL and want your tables to use the MyISAM table
|
||||
type, use the following SQL::
|
||||
type, use the following SQL:
|
||||
|
||||
.. code-block:: sql
|
||||
|
||||
ALTER TABLE myapp_mytable ENGINE=MyISAM;
|
||||
|
||||
@@ -36,7 +36,9 @@ I'm getting a ``UnicodeDecodeError``. What am I doing wrong?
|
||||
|
||||
This class of errors happen when a bytestring containing non-ASCII sequences is
|
||||
transformed into a Unicode string and the specified encoding is incorrect. The
|
||||
output generally looks like this::
|
||||
output generally looks like this:
|
||||
|
||||
.. code-block:: pytb
|
||||
|
||||
UnicodeDecodeError: 'ascii' codec can't decode byte 0x?? in position ?:
|
||||
ordinal not in range(128)
|
||||
|
||||
Reference in New Issue
Block a user