Fixed #26021 -- Applied hanging indentation to docs.

This commit is contained in:
Ed Henderson 2016-06-02 12:56:13 -07:00 committed by Tim Graham
parent 38575b007a
commit 4a4d7f980e
21 changed files with 185 additions and 107 deletions

View file

@ -615,10 +615,12 @@ subclass::
color_code = models.CharField(max_length=6)
def colored_name(self):
return format_html('<span style="color: #{};">{} {}</span>',
self.color_code,
self.first_name,
self.last_name)
return format_html(
'<span style="color: #{};">{} {}</span>',
self.color_code,
self.first_name,
self.last_name,
)
class PersonAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'colored_name')
@ -700,9 +702,11 @@ subclass::
color_code = models.CharField(max_length=6)
def colored_first_name(self):
return format_html('<span style="color: #{};">{}</span>',
self.color_code,
self.first_name)
return format_html(
'<span style="color: #{};">{}</span>',
self.color_code,
self.first_name,
)
colored_first_name.admin_order_field = 'first_name'
@ -906,13 +910,11 @@ subclass::
def lookups(self, request, model_admin):
if request.user.is_superuser:
return super(AuthDecadeBornListFilter,
self).lookups(request, model_admin)
return super(AuthDecadeBornListFilter, self).lookups(request, model_admin)
def queryset(self, request, queryset):
if request.user.is_superuser:
return super(AuthDecadeBornListFilter,
self).queryset(request, queryset)
return super(AuthDecadeBornListFilter, self).queryset(request, queryset)
Also as a convenience, the ``ModelAdmin`` object is passed to
the ``lookups`` method, for example if you want to base the
@ -1268,8 +1270,8 @@ subclass::
class PersonAdmin(admin.ModelAdmin):
def view_on_site(self, obj):
return 'https://example.com' + reverse('person-detail',
kwargs={'slug': obj.slug})
url = reverse('person-detail', kwargs={'slug': obj.slug})
return 'https://example.com' + url
Custom template options
~~~~~~~~~~~~~~~~~~~~~~~
@ -1875,8 +1877,9 @@ provided some extra mapping data that would not otherwise be available::
def change_view(self, request, object_id, form_url='', extra_context=None):
extra_context = extra_context or {}
extra_context['osm_data'] = self.get_osm_info()
return super(MyModelAdmin, self).change_view(request, object_id,
form_url, extra_context=extra_context)
return super(MyModelAdmin, self).change_view(
request, object_id, form_url, extra_context=extra_context,
)
These views return :class:`~django.template.response.TemplateResponse`
instances which allow you to easily customize the response data before

View file

@ -120,7 +120,7 @@ raster models::
>>> from django.contrib.gis.gdal import GDALRaster
>>> rast = GDALRaster({'width': 10, 'height': 10, 'name': 'Canyon', 'srid': 4326,
... 'scale': [0.1, -0.1]'bands': [{"data": range(100)}]}
... 'scale': [0.1, -0.1], 'bands': [{"data": range(100)}]})
>>> dem = Elevation(name='Canyon', rast=rast)
>>> dem.save()
@ -129,7 +129,7 @@ Note that this equivalent to::
>>> dem = Elevation.objects.create(
... name='Canyon',
... rast={'width': 10, 'height': 10, 'name': 'Canyon', 'srid': 4326,
... 'scale': [0.1, -0.1]'bands': [{"data": range(100)}]}
... 'scale': [0.1, -0.1], 'bands': [{"data": range(100)}]},
... )
.. _spatial-lookups-intro:

View file

@ -452,12 +452,15 @@ with the following code::
'mpoly' : 'MULTIPOLYGON',
}
world_shp = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data', 'TM_WORLD_BORDERS-0.3.shp'))
world_shp = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'data', 'TM_WORLD_BORDERS-0.3.shp'),
)
def run(verbose=True):
lm = LayerMapping(WorldBorder, world_shp, world_mapping,
transform=False, encoding='iso-8859-1')
lm = LayerMapping(
WorldBorder, world_shp, world_mapping,
transform=False, encoding='iso-8859-1',
)
lm.save(strict=True, verbose=verbose)
A few notes about what's going on:

View file

@ -320,8 +320,7 @@ Adding extra message tags
For more direct control over message tags, you can optionally provide a string
containing extra tags to any of the add methods::
messages.add_message(request, messages.INFO, 'Over 9000!',
extra_tags='dragonball')
messages.add_message(request, messages.INFO, 'Over 9000!', extra_tags='dragonball')
messages.error(request, 'Email box full', extra_tags='email')
Extra tags are added before the default tag for that level and are space
@ -336,8 +335,10 @@ if they don't want to, you may pass an additional keyword argument
``fail_silently=True`` to any of the ``add_message`` family of methods. For
example::
messages.add_message(request, messages.SUCCESS, 'Profile details updated.',
fail_silently=True)
messages.add_message(
request, messages.SUCCESS, 'Profile details updated.',
fail_silently=True,
)
messages.info(request, 'Hello world.', fail_silently=True)
.. note::

View file

@ -197,10 +197,14 @@ Here's an example of what the form-handling view looks like::
# ...
current_site = get_current_site(request)
send_mail('Thanks for subscribing to %s alerts' % current_site.name,
'Thanks for your subscription. We appreciate it.\n\n-The %s team.' % current_site.name,
send_mail(
'Thanks for subscribing to %s alerts' % current_site.name,
'Thanks for your subscription. We appreciate it.\n\n-The %s team.' % (
current_site.name,
),
'editor@%s' % current_site.domain,
[user.email])
[user.email],
)
# ...

View file

@ -998,16 +998,25 @@ Slightly complex built-in ``Field`` classes
}
# Or define a different message for each field.
fields = (
CharField(error_messages={'incomplete': 'Enter a country calling code.'},
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid country calling code.')]),
CharField(error_messages={'incomplete': 'Enter a phone number.'},
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid phone number.')]),
CharField(validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid extension.')],
required=False),
CharField(
error_messages={'incomplete': 'Enter a country calling code.'},
validators=[
RegexValidator(r'^[0-9]+$', 'Enter a valid country calling code.'),
],
),
CharField(
error_messages={'incomplete': 'Enter a phone number.'},
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid phone number.')],
),
CharField(
validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid extension.')],
required=False,
),
)
super(PhoneField, self).__init__(
error_messages=error_messages, fields=fields,
require_all_fields=False, *args, **kwargs)
require_all_fields=False, *args, **kwargs
)
.. attribute:: MultiValueField.widget

View file

@ -62,8 +62,11 @@ widget on the field. In the following example, the
class SimpleForm(forms.Form):
birth_year = forms.DateField(widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES))
favorite_colors = forms.MultipleChoiceField(required=False,
widget=forms.CheckboxSelectMultiple, choices=FAVORITE_COLORS_CHOICES)
favorite_colors = forms.MultipleChoiceField(
required=False,
widget=forms.CheckboxSelectMultiple,
choices=FAVORITE_COLORS_CHOICES,
)
See the :ref:`built-in widgets` for more information about which widgets
are available and which arguments they accept.

View file

@ -371,7 +371,8 @@ SQL that is generated. Here's a brief example::
expression,
distinct='DISTINCT ' if distinct else '',
output_field=IntegerField(),
**extra)
**extra
)
``Value()`` expressions

View file

@ -112,9 +112,11 @@ define a suitably-named constant for each value::
(JUNIOR, 'Junior'),
(SENIOR, 'Senior'),
)
year_in_school = models.CharField(max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
default=FRESHMAN)
year_in_school = models.CharField(
max_length=2,
choices=YEAR_IN_SCHOOL_CHOICES,
default=FRESHMAN,
)
def is_upperclass(self):
return self.year_in_school in (self.JUNIOR, self.SENIOR)