mirror of https://github.com/django/django.git
Fixed typos spotted by Claude Paroz
This commit is contained in:
parent
f468662e24
commit
4dc3be2506
|
@ -88,7 +88,7 @@ application where we want to make use of the ``abs()`` operator.
|
||||||
We have an ``Experiment`` model which records a start value, end value and the
|
We have an ``Experiment`` model which records a start value, end value and the
|
||||||
change (start - end). We would like to find all experiments where the change
|
change (start - end). We would like to find all experiments where the change
|
||||||
was equal to a certain amount (``Experiment.objects.filter(change__abs=27)``),
|
was equal to a certain amount (``Experiment.objects.filter(change__abs=27)``),
|
||||||
or where it did not exceede a certain amount
|
or where it did not exceed a certain amount
|
||||||
(``Experiment.objects.filter(change__abs__lt=27)``).
|
(``Experiment.objects.filter(change__abs__lt=27)``).
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
@ -113,7 +113,7 @@ Next, lets register it for ``IntegerField``::
|
||||||
from django.db.models import IntegerField
|
from django.db.models import IntegerField
|
||||||
IntegerField.register_lookup(AbsoluteValue)
|
IntegerField.register_lookup(AbsoluteValue)
|
||||||
|
|
||||||
We can now run the queris we had before.
|
We can now run the queries we had before.
|
||||||
``Experiment.objects.filter(change__abs=27)`` will generate the following SQL::
|
``Experiment.objects.filter(change__abs=27)`` will generate the following SQL::
|
||||||
|
|
||||||
SELECT ... WHERE ABS("experiments"."change") = 27
|
SELECT ... WHERE ABS("experiments"."change") = 27
|
||||||
|
@ -184,13 +184,13 @@ transformations in Python.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
In fact, most lookups with ``__abs`` could be implemented as range queries
|
In fact, most lookups with ``__abs`` could be implemented as range queries
|
||||||
like this, and on most database backend it is likely to be more sensible to
|
like this, and on most database backends it is likely to be more sensible to
|
||||||
do so as you can make use of the indexes. However with PostgreSQL you may
|
do so as you can make use of the indexes. However with PostgreSQL you may
|
||||||
want to add an index on ``abs(change)`` which would allow these queries to
|
want to add an index on ``abs(change)`` which would allow these queries to
|
||||||
be very efficient.
|
be very efficient.
|
||||||
|
|
||||||
Writing alternative implemenatations for existing lookups
|
Writing alternative implementations for existing lookups
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Sometimes different database vendors require different SQL for the same
|
Sometimes different database vendors require different SQL for the same
|
||||||
operation. For this example we will rewrite a custom implementation for
|
operation. For this example we will rewrite a custom implementation for
|
||||||
|
@ -210,7 +210,7 @@ We can change the behaviour on a specific backend by creating a subclass of
|
||||||
Field.register_lookup(MySQLNotExact)
|
Field.register_lookup(MySQLNotExact)
|
||||||
|
|
||||||
We can then register it with ``Field``. It takes the place of the original
|
We can then register it with ``Field``. It takes the place of the original
|
||||||
``NotEqual`` class as it has
|
``NotEqual`` class as it has the same ``lookup_name``.
|
||||||
|
|
||||||
When compiling a query, Django first looks for ``as_%s % connection.vendor``
|
When compiling a query, Django first looks for ``as_%s % connection.vendor``
|
||||||
methods, and then falls back to ``as_sql``. The vendor names for the in-built
|
methods, and then falls back to ``as_sql``. The vendor names for the in-built
|
||||||
|
|
|
@ -189,7 +189,7 @@ Custom lookups work just like Django's inbuilt lookups (e.g. ``lte``,
|
||||||
|
|
||||||
The :class:`django.db.models.Lookup` class provides a way to add lookup
|
The :class:`django.db.models.Lookup` class provides a way to add lookup
|
||||||
operators for model fields. As an example it is possible to add ``day_lte``
|
operators for model fields. As an example it is possible to add ``day_lte``
|
||||||
opertor for ``DateFields``.
|
operator for ``DateFields``.
|
||||||
|
|
||||||
The :class:`django.db.models.Transform` class allows transformations of
|
The :class:`django.db.models.Transform` class allows transformations of
|
||||||
database values prior to the final lookup. For example it is possible to
|
database values prior to the final lookup. For example it is possible to
|
||||||
|
|
Loading…
Reference in New Issue