summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2018-05-12 19:37:42 +0200
committerGitHub <noreply@github.com>2018-05-12 19:37:42 +0200
commit35319bf12ccefe1911588493484160aa49208f89 (patch)
treefe1cb029786e49622e6ba3af3ddf3dc9956502ff /docs/ref
parent1b7d524cfa7b7834af26c99407af66be6813938d (diff)
Alphabetized imports in various docs.
Follow-up of d97cce34096043b019e818a7fb98c0f9f073704c and 7d3fe36c626a3268413eb86d37920f132eb4a54f.
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/class-based-views/generic-display.txt4
-rw-r--r--docs/ref/class-based-views/generic-editing.txt4
-rw-r--r--docs/ref/contrib/admin/actions.txt2
-rw-r--r--docs/ref/contrib/admin/index.txt20
-rw-r--r--docs/ref/contrib/contenttypes.txt4
-rw-r--r--docs/ref/contrib/gis/measure.txt2
-rw-r--r--docs/ref/contrib/gis/tutorial.txt4
-rw-r--r--docs/ref/contrib/postgres/forms.txt4
-rw-r--r--docs/ref/contrib/sites.txt10
-rw-r--r--docs/ref/contrib/syndication.txt2
-rw-r--r--docs/ref/csrf.txt6
-rw-r--r--docs/ref/forms/validation.txt2
-rw-r--r--docs/ref/models/conditional-expressions.txt4
-rw-r--r--docs/ref/models/database-functions.txt2
-rw-r--r--docs/ref/models/expressions.txt4
-rw-r--r--docs/ref/models/instances.txt2
-rw-r--r--docs/ref/urlresolvers.txt2
17 files changed, 39 insertions, 39 deletions
diff --git a/docs/ref/class-based-views/generic-display.txt b/docs/ref/class-based-views/generic-display.txt
index 15d3351d48..044f16d9e5 100644
--- a/docs/ref/class-based-views/generic-display.txt
+++ b/docs/ref/class-based-views/generic-display.txt
@@ -38,8 +38,8 @@ many projects they are typically the most commonly used views.
**Example myapp/views.py**::
- from django.views.generic.detail import DetailView
from django.utils import timezone
+ from django.views.generic.detail import DetailView
from articles.models import Article
@@ -107,8 +107,8 @@ many projects they are typically the most commonly used views.
**Example views.py**::
- from django.views.generic.list import ListView
from django.utils import timezone
+ from django.views.generic.list import ListView
from articles.models import Article
diff --git a/docs/ref/class-based-views/generic-editing.txt b/docs/ref/class-based-views/generic-editing.txt
index 969a033a31..7979eb19b7 100644
--- a/docs/ref/class-based-views/generic-editing.txt
+++ b/docs/ref/class-based-views/generic-editing.txt
@@ -15,8 +15,8 @@ editing content:
Some of the examples on this page assume that an ``Author`` model has been
defined as follows in ``myapp/models.py``::
- from django.urls import reverse
from django.db import models
+ from django.urls import reverse
class Author(models.Model):
name = models.CharField(max_length=200)
@@ -226,8 +226,8 @@ editing content:
**Example myapp/views.py**::
- from django.views.generic.edit import DeleteView
from django.urls import reverse_lazy
+ from django.views.generic.edit import DeleteView
from myapp.models import Author
class AuthorDelete(DeleteView):
diff --git a/docs/ref/contrib/admin/actions.txt b/docs/ref/contrib/admin/actions.txt
index c23c647a72..0eb6de5b11 100644
--- a/docs/ref/contrib/admin/actions.txt
+++ b/docs/ref/contrib/admin/actions.txt
@@ -220,8 +220,8 @@ example, you might write a simple export function that uses Django's
:doc:`serialization functions </topics/serialization>` to dump some selected
objects as JSON::
- from django.http import HttpResponse
from django.core import serializers
+ from django.http import HttpResponse
def export_as_json(modeladmin, request, queryset):
response = HttpResponse(content_type="application/json")
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt
index 29bd436fe0..3cf13572a2 100644
--- a/docs/ref/contrib/admin/index.txt
+++ b/docs/ref/contrib/admin/index.txt
@@ -128,7 +128,7 @@ The ``register`` decorator
argument::
from django.contrib import admin
- from .models import Author, Reader, Editor
+ from .models import Author, Editor, Reader
from myproject.admin_site import custom_admin_site
@admin.register(Author, Reader, Editor, site=custom_admin_site)
@@ -502,12 +502,12 @@ subclass::
that we'd like to use for large text fields instead of the default
``<textarea>``. Here's how we'd do that::
- from django.db import models
from django.contrib import admin
+ from django.db import models
# Import our custom widget and our model from where they're defined
- from myapp.widgets import RichTextEditorWidget
from myapp.models import MyModel
+ from myapp.widgets import RichTextEditorWidget
class MyModelAdmin(admin.ModelAdmin):
formfield_overrides = {
@@ -581,8 +581,8 @@ subclass::
the same as the callable, but ``self`` in this context is the model
instance. Here's a full model example::
- from django.db import models
from django.contrib import admin
+ from django.db import models
class Person(models.Model):
name = models.CharField(max_length=50)
@@ -616,8 +616,8 @@ subclass::
Here's a full example model::
- from django.db import models
from django.contrib import admin
+ from django.db import models
from django.utils.html import format_html
class Person(models.Model):
@@ -670,8 +670,8 @@ subclass::
Here's a full example model::
- from django.db import models
from django.contrib import admin
+ from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=50)
@@ -699,8 +699,8 @@ subclass::
For example::
- from django.db import models
from django.contrib import admin
+ from django.db import models
from django.utils.html import format_html
class Person(models.Model):
@@ -2572,8 +2572,8 @@ Using generic relations as an inline
It is possible to use an inline with generically related objects. Let's say
you have the following models::
- from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
+ from django.db import models
class Image(models.Model):
image = models.ImageField(upload_to="images")
@@ -3001,7 +3001,7 @@ respectively::
# urls.py
from django.urls import path
- from myproject.admin import basic_site, advanced_site
+ from myproject.admin import advanced_site, basic_site
urlpatterns = [
path('basic-admin/', basic_site.urls),
@@ -3111,7 +3111,7 @@ password box.
For example, to get a list of all additions done through the admin::
- from django.contrib.admin.models import LogEntry, ADDITION
+ from django.contrib.admin.models import ADDITION, LogEntry
LogEntry.objects.filter(action_flag=ADDITION)
diff --git a/docs/ref/contrib/contenttypes.txt b/docs/ref/contrib/contenttypes.txt
index bc73308b69..e01001baf7 100644
--- a/docs/ref/contrib/contenttypes.txt
+++ b/docs/ref/contrib/contenttypes.txt
@@ -241,9 +241,9 @@ generic (sometimes called "polymorphic") relationships between models.
A simple example is a tagging system, which might look like this::
- from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
+ from django.db import models
class TaggedItem(models.Model):
tag = models.SlugField()
@@ -371,8 +371,8 @@ Reverse generic relations
If you know which models you'll be using most often, you can also add
a "reverse" generic relationship to enable an additional API. For example::
- from django.db import models
from django.contrib.contenttypes.fields import GenericRelation
+ from django.db import models
class Bookmark(models.Model):
url = models.URLField()
diff --git a/docs/ref/contrib/gis/measure.txt b/docs/ref/contrib/gis/measure.txt
index 2c76ccdbad..d85ebab31b 100644
--- a/docs/ref/contrib/gis/measure.txt
+++ b/docs/ref/contrib/gis/measure.txt
@@ -18,7 +18,7 @@ Example
context of the units. In the example below, two different distance objects are
instantiated in units of kilometers (``km``) and miles (``mi``)::
- >>> from django.contrib.gis.measure import Distance, D
+ >>> from django.contrib.gis.measure import D, Distance
>>> d1 = Distance(km=5)
>>> print(d1)
5.0 km
diff --git a/docs/ref/contrib/gis/tutorial.txt b/docs/ref/contrib/gis/tutorial.txt
index 8ffa41d4a2..7c730e41aa 100644
--- a/docs/ref/contrib/gis/tutorial.txt
+++ b/docs/ref/contrib/gis/tutorial.txt
@@ -620,7 +620,7 @@ example, coordinates will be expressed in `EPSG SRID 32140`__,
a coordinate system specific to south Texas **only** and in units of
**meters**, not degrees::
- >>> from django.contrib.gis.geos import Point, GEOSGeometry
+ >>> from django.contrib.gis.geos import GEOSGeometry, Point
>>> pnt = Point(954158.1, 4215137.1, srid=32140)
Note that ``pnt`` may also be constructed with EWKT, an "extended" form of
@@ -722,7 +722,7 @@ Let's dive right in. Create a file called ``admin.py`` inside the
Next, edit your ``urls.py`` in the ``geodjango`` application folder as follows::
from django.contrib.gis import admin
- from django.urls import path, include
+ from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
diff --git a/docs/ref/contrib/postgres/forms.txt b/docs/ref/contrib/postgres/forms.txt
index 61b5a26eb6..04adbc3a40 100644
--- a/docs/ref/contrib/postgres/forms.txt
+++ b/docs/ref/contrib/postgres/forms.txt
@@ -26,8 +26,8 @@ Fields
to render any HTML, but it is used to process the submitted data and
validate it. For example::
- >>> from django.contrib.postgres.forms import SimpleArrayField
>>> from django import forms
+ >>> from django.contrib.postgres.forms import SimpleArrayField
>>> class NumberListForm(forms.Form):
... numbers = SimpleArrayField(forms.IntegerField())
@@ -48,8 +48,8 @@ Fields
value is used to split the submitted data. It allows you to chain
``SimpleArrayField`` for multidimensional data::
- >>> from django.contrib.postgres.forms import SimpleArrayField
>>> from django import forms
+ >>> from django.contrib.postgres.forms import SimpleArrayField
>>> class GridForm(forms.Form):
... places = SimpleArrayField(SimpleArrayField(IntegerField()), delimiter='|')
diff --git a/docs/ref/contrib/sites.txt b/docs/ref/contrib/sites.txt
index dc8ac87e80..b5c3889bef 100644
--- a/docs/ref/contrib/sites.txt
+++ b/docs/ref/contrib/sites.txt
@@ -63,8 +63,8 @@ article is associated with one or more sites. In Django model terminology,
that's represented by a :class:`~django.db.models.ManyToManyField` in the
``Article`` model::
- from django.db import models
from django.contrib.sites.models import Site
+ from django.db import models
class Article(models.Model):
headline = models.CharField(max_length=200)
@@ -106,8 +106,8 @@ model in a many-to-one relationship, using
For example, if an article is only allowed on a single site, you'd use a model
like this::
- from django.db import models
from django.contrib.sites.models import Site
+ from django.db import models
class Article(models.Model):
headline = models.CharField(max_length=200)
@@ -218,7 +218,7 @@ different template directories (:setting:`DIRS <TEMPLATES-DIRS>`), you could
simply farm out to the template system like so::
from django.core.mail import send_mail
- from django.template import loader, Context
+ from django.template import Context, loader
def register_for_newsletter(request):
# Check form values, etc., and subscribe the user.
@@ -325,9 +325,9 @@ with the current :class:`~django.contrib.sites.models.Site`.
Use :class:`~django.contrib.sites.managers.CurrentSiteManager` by adding it to
your model explicitly. For example::
- from django.db import models
from django.contrib.sites.models import Site
from django.contrib.sites.managers import CurrentSiteManager
+ from django.db import models
class Photo(models.Model):
photo = models.FileField(upload_to='photos')
@@ -362,9 +362,9 @@ a parameter to
model. The following model, which has a field called ``publish_on``,
demonstrates this::
- from django.db import models
from django.contrib.sites.models import Site
from django.contrib.sites.managers import CurrentSiteManager
+ from django.db import models
class Photo(models.Model):
photo = models.FileField(upload_to='photos')
diff --git a/docs/ref/contrib/syndication.txt b/docs/ref/contrib/syndication.txt
index 0685c4c90d..ab3fcba5d4 100644
--- a/docs/ref/contrib/syndication.txt
+++ b/docs/ref/contrib/syndication.txt
@@ -367,7 +367,7 @@ Here's a full example::
And the accompanying URLconf::
from django.urls import path
- from myproject.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
+ from myproject.feeds import AtomSiteNewsFeed, RssSiteNewsFeed
urlpatterns = [
# ...
diff --git a/docs/ref/csrf.txt b/docs/ref/csrf.txt
index 2664a6270f..a66ca237e0 100644
--- a/docs/ref/csrf.txt
+++ b/docs/ref/csrf.txt
@@ -202,8 +202,8 @@ both is fine, and will incur minimal overhead.
Usage::
- from django.views.decorators.csrf import csrf_protect
from django.shortcuts import render
+ from django.views.decorators.csrf import csrf_protect
@csrf_protect
def my_view(request):
@@ -400,8 +400,8 @@ class-based views<decorating-class-based-views>`.
This decorator marks a view as being exempt from the protection ensured by
the middleware. Example::
- from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse
+ from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def my_view(request):
@@ -417,8 +417,8 @@ class-based views<decorating-class-based-views>`.
Example::
- from django.views.decorators.csrf import requires_csrf_token
from django.shortcuts import render
+ from django.views.decorators.csrf import requires_csrf_token
@requires_csrf_token
def my_view(request):
diff --git a/docs/ref/forms/validation.txt b/docs/ref/forms/validation.txt
index 91e18e5b33..72af31d907 100644
--- a/docs/ref/forms/validation.txt
+++ b/docs/ref/forms/validation.txt
@@ -229,8 +229,8 @@ defined on the :class:`~django.forms.Field` class itself with the
Simple validators can be used to validate values inside the field, let's have
a look at Django's ``SlugField``::
- from django.forms import CharField
from django.core import validators
+ from django.forms import CharField
class SlugField(CharField):
default_validators = [validators.validate_slug]
diff --git a/docs/ref/models/conditional-expressions.txt b/docs/ref/models/conditional-expressions.txt
index 643bdddae0..80146917d7 100644
--- a/docs/ref/models/conditional-expressions.txt
+++ b/docs/ref/models/conditional-expressions.txt
@@ -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,
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt
index d86853cc12..494c175843 100644
--- a/docs/ref/models/database-functions.txt
+++ b/docs/ref/models/database-functions.txt
@@ -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
diff --git a/docs/ref/models/expressions.txt b/docs/ref/models/expressions.txt
index 1fdc5f7116..a929e8a98f 100644
--- a/docs/ref/models/expressions.txt
+++ b/docs/ref/models/expressions.txt
@@ -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'))
diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt
index 73bbeb8f31..23572f7362 100644
--- a/docs/ref/models/instances.txt
+++ b/docs/ref/models/instances.txt
@@ -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:
diff --git a/docs/ref/urlresolvers.txt b/docs/ref/urlresolvers.txt
index aa814a9e40..0afdc4430f 100644
--- a/docs/ref/urlresolvers.txt
+++ b/docs/ref/urlresolvers.txt
@@ -176,7 +176,7 @@ view would raise a ``Http404`` error before redirecting to it::
from urllib.parse import urlparse
from django.urls import resolve
- from django.http import HttpResponseRedirect, Http404
+ from django.http import Http404, HttpResponseRedirect
def myview(request):
next = request.META.get('HTTP_REFERER', None) or '/'