Skip to content

Commit

Permalink
[2.0.x] Alphabetized imports in various docs.
Browse files Browse the repository at this point in the history
Follow-up of d97cce3 and 7d3fe36.
Backport of 35319bf from master
  • Loading branch information
felixxm committed May 12, 2018
1 parent 840c0ed commit 80a5320
Show file tree
Hide file tree
Showing 36 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion docs/howto/outputting-csv.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ template output the commas in a :ttag:`for` loop.
Here's an example, which generates the same CSV file as above::

from django.http import HttpResponse
from django.template import loader, Context
from django.template import Content, loader

def some_view(request):
# Create the HttpResponse object with the appropriate CSV header.
Expand Down
2 changes: 1 addition & 1 deletion docs/howto/outputting-pdf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ objects are file-like objects.

Here's a "Hello World" example::

from reportlab.pdfgen import canvas
from django.http import HttpResponse
from reportlab.pdfgen import canvas

def some_view(request):
# Create the HttpResponse object with the appropriate PDF headers.
Expand Down
2 changes: 1 addition & 1 deletion docs/intro/overview.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ necessary:
.. code-block:: python

# Import the models we created from our "news" app
>>> from news.models import Reporter, Article
>>> from news.models import Article, Reporter

# No reporters are in the system yet.
>>> Reporter.objects.all()
Expand Down
4 changes: 2 additions & 2 deletions docs/intro/tutorial02.txt
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ the Python import path to your :file:`mysite/settings.py` file.

Once you're in the shell, explore the :doc:`database API </topics/db/queries>`::

>>> from polls.models import Question, Choice # Import the model classes we just wrote.
>>> from polls.models import Choice, Question # Import the model classes we just wrote.

# No questions are in the system yet.
>>> Question.objects.all()
Expand Down Expand Up @@ -469,7 +469,7 @@ the :doc:`time zone support docs </topics/i18n/timezones>`.
Save these changes and start a new Python interactive shell by running
``python manage.py shell`` again::

>>> from polls.models import Question, Choice
>>> from polls.models import Choice, Question

# Make sure our __str__() addition worked.
>>> Question.objects.all()
Expand Down
4 changes: 2 additions & 2 deletions docs/intro/tutorial04.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ create a real version. Add the following to ``polls/views.py``:
.. snippet::
:filename: polls/views.py

from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect, HttpResponse
from django.urls import reverse

from .models import Choice, Question
Expand Down Expand Up @@ -262,8 +262,8 @@ views and use Django's generic views instead. To do so, open the
.. snippet::
:filename: polls/views.py

from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.views import generic

Expand Down
2 changes: 1 addition & 1 deletion docs/intro/tutorial05.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ Put the following in the ``tests.py`` file in the ``polls`` application:

import datetime

from django.utils import timezone
from django.test import TestCase
from django.utils import timezone

from .models import Question

Expand Down
4 changes: 2 additions & 2 deletions docs/ref/class-based-views/generic-display.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions docs/ref/class-based-views/generic-editing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/contrib/admin/actions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,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")
Expand Down
20 changes: 10 additions & 10 deletions docs/ref/contrib/admin/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -497,12 +497,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 = {
Expand Down Expand Up @@ -576,8 +576,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)
Expand Down Expand Up @@ -612,8 +612,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):
Expand Down Expand Up @@ -666,8 +666,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)
Expand Down Expand Up @@ -695,8 +695,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):
Expand Down Expand Up @@ -2473,8 +2473,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")
Expand Down Expand Up @@ -2848,7 +2848,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),
Expand Down Expand Up @@ -2958,7 +2958,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)

Expand Down
4 changes: 2 additions & 2 deletions docs/ref/contrib/contenttypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/contrib/gis/measure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/ref/contrib/gis/tutorial.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions docs/ref/contrib/postgres/forms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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='|')
Expand Down
10 changes: 5 additions & 5 deletions docs/ref/contrib/sites.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/contrib/syndication.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
# ...
Expand Down
6 changes: 3 additions & 3 deletions docs/ref/csrf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -405,8 +405,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):
Expand All @@ -422,8 +422,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):
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/forms/validation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading

0 comments on commit 80a5320

Please sign in to comment.