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],
)
# ...