mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Removed unnecessary code-block directives.
This commit is contained in:
@@ -12,7 +12,7 @@ collection of objects. This topic guide describes the ways that aggregate values
|
||||
can be generated and returned using Django queries.
|
||||
|
||||
Throughout this guide, we'll refer to the following models. These models are
|
||||
used to track the inventory for a series of online bookstores:
|
||||
used to track the inventory for a series of online bookstores::
|
||||
|
||||
.. _queryset-model-example:
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@
|
||||
Many-to-one relationships
|
||||
#########################
|
||||
|
||||
.. highlight:: pycon
|
||||
|
||||
To define a many-to-one relationship, use :class:`~django.db.models.ForeignKey`.
|
||||
|
||||
.. code-block:: python
|
||||
To define a many-to-one relationship, use :class:`~django.db.models.ForeignKey`::
|
||||
|
||||
from django.db import models
|
||||
|
||||
@@ -32,6 +28,8 @@ To define a many-to-one relationship, use :class:`~django.db.models.ForeignKey`.
|
||||
What follows are examples of operations that can be performed using the Python
|
||||
API facilities.
|
||||
|
||||
.. highlight:: pycon
|
||||
|
||||
Create a few Reporters::
|
||||
|
||||
>>> r = Reporter(first_name='John', last_name='Smith', email='john@example.com')
|
||||
|
||||
@@ -2,13 +2,9 @@
|
||||
One-to-one relationships
|
||||
########################
|
||||
|
||||
.. highlight:: pycon
|
||||
|
||||
To define a one-to-one relationship, use :ref:`ref-onetoone`.
|
||||
|
||||
In this example, a ``Place`` optionally can be a ``Restaurant``:
|
||||
|
||||
.. code-block:: python
|
||||
In this example, a ``Place`` optionally can be a ``Restaurant``::
|
||||
|
||||
from django.db import models
|
||||
|
||||
@@ -37,6 +33,8 @@ In this example, a ``Place`` optionally can be a ``Restaurant``:
|
||||
What follows are examples of operations that can be performed using the Python
|
||||
API facilities.
|
||||
|
||||
.. highlight:: pycon
|
||||
|
||||
Create a couple of Places::
|
||||
|
||||
>>> p1 = Place(name='Demon Dogs', address='944 W. Fullerton')
|
||||
|
||||
@@ -24,9 +24,7 @@ the alias of ``default`` when no other database has been selected.
|
||||
|
||||
The following is an example ``settings.py`` snippet defining two
|
||||
databases -- a default PostgreSQL database and a MySQL database called
|
||||
``users``:
|
||||
|
||||
.. code-block:: python
|
||||
``users``::
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
|
||||
@@ -324,16 +324,12 @@ manager.
|
||||
|
||||
.. _`Python ticket #9220`: http://bugs.python.org/issue9220
|
||||
|
||||
Using a cursor as a context manager:
|
||||
|
||||
.. code-block:: python
|
||||
Using a cursor as a context manager::
|
||||
|
||||
with connection.cursor() as c:
|
||||
c.execute(...)
|
||||
|
||||
is equivalent to:
|
||||
|
||||
.. code-block:: python
|
||||
is equivalent to::
|
||||
|
||||
c = connection.cursor()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user