diff options
Diffstat (limited to 'docs/ref/contrib')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 33 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/db-api.txt | 4 | ||||
| -rw-r--r-- | docs/ref/contrib/gis/tutorial.txt | 11 | ||||
| -rw-r--r-- | docs/ref/contrib/messages.txt | 9 | ||||
| -rw-r--r-- | docs/ref/contrib/sites.txt | 10 |
5 files changed, 39 insertions, 28 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 66b116ad35..d5afca2c88 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -617,10 +617,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') @@ -706,9 +708,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' @@ -912,13 +916,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 @@ -1274,8 +1276,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 ~~~~~~~~~~~~~~~~~~~~~~~ @@ -1885,8 +1887,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 diff --git a/docs/ref/contrib/gis/db-api.txt b/docs/ref/contrib/gis/db-api.txt index 4403fff392..0b1f7d3d0b 100644 --- a/docs/ref/contrib/gis/db-api.txt +++ b/docs/ref/contrib/gis/db-api.txt @@ -122,7 +122,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() @@ -131,7 +131,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: diff --git a/docs/ref/contrib/gis/tutorial.txt b/docs/ref/contrib/gis/tutorial.txt index 8f597df9fb..5d753a327e 100644 --- a/docs/ref/contrib/gis/tutorial.txt +++ b/docs/ref/contrib/gis/tutorial.txt @@ -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: diff --git a/docs/ref/contrib/messages.txt b/docs/ref/contrib/messages.txt index 414cf21116..3343707d69 100644 --- a/docs/ref/contrib/messages.txt +++ b/docs/ref/contrib/messages.txt @@ -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:: diff --git a/docs/ref/contrib/sites.txt b/docs/ref/contrib/sites.txt index ec2c1bf2b2..557795b691 100644 --- a/docs/ref/contrib/sites.txt +++ b/docs/ref/contrib/sites.txt @@ -202,10 +202,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], + ) # ... |
