mirror of
https://github.com/django/django.git
synced 2025-12-09 19:08:06 +00:00
Alphabetized imports in various docs.
Follow-up ofd97cce3409and7d3fe36c62.
This commit is contained in:
parent
1b7d524cfa
commit
35319bf12c
36 changed files with 71 additions and 71 deletions
|
|
@ -48,7 +48,7 @@ keyword.
|
|||
|
||||
Some examples::
|
||||
|
||||
>>> from django.db.models import When, F, Q
|
||||
>>> from django.db.models import F, Q, When
|
||||
>>> # String arguments refer to fields; the following two examples are equivalent:
|
||||
>>> When(account_type=Client.GOLD, then='name')
|
||||
>>> When(account_type=Client.GOLD, then=F('name'))
|
||||
|
|
@ -88,7 +88,7 @@ A simple example::
|
|||
|
||||
>>>
|
||||
>>> from datetime import date, timedelta
|
||||
>>> from django.db.models import CharField, Case, Value, When
|
||||
>>> from django.db.models import Case, CharField, Value, When
|
||||
>>> Client.objects.create(
|
||||
... name='Jane Doe',
|
||||
... account_type=Client.REGULAR,
|
||||
|
|
|
|||
|
|
@ -979,7 +979,7 @@ than 0. If ``length`` is ``None``, then the rest of the string will be returned.
|
|||
Usage example::
|
||||
|
||||
>>> # Set the alias to the first 5 characters of the name as lowercase
|
||||
>>> from django.db.models.functions import Substr, Lower
|
||||
>>> from django.db.models.functions import Lower, Substr
|
||||
>>> Author.objects.create(name='Margaret Smith')
|
||||
>>> Author.objects.update(alias=Lower(Substr('name', 1, 5)))
|
||||
1
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Some examples
|
|||
|
||||
.. code-block:: python
|
||||
|
||||
from django.db.models import F, Count, Value
|
||||
from django.db.models import Count, F, Value
|
||||
from django.db.models.functions import Length, Upper
|
||||
|
||||
# Find companies that have more employees than chairs.
|
||||
|
|
@ -252,7 +252,7 @@ is null) after companies that have been contacted::
|
|||
database functions like ``COALESCE`` and ``LOWER``, or aggregates like ``SUM``.
|
||||
They can be used directly::
|
||||
|
||||
from django.db.models import Func, F
|
||||
from django.db.models import F, Func
|
||||
|
||||
queryset.annotate(field_lower=Func(F('field'), function='LOWER'))
|
||||
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ will be stored in a special error dictionary key,
|
|||
:data:`~django.core.exceptions.NON_FIELD_ERRORS`. This key is used for errors
|
||||
that are tied to the entire model instead of to a specific field::
|
||||
|
||||
from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
|
||||
from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
|
||||
try:
|
||||
article.full_clean()
|
||||
except ValidationError as e:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue