mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Applied Black's 2024 stable style.
https://github.com/psf/black/releases/tag/24.1.0
This commit is contained in:
parent
3f6d939c62
commit
305757aec1
235 changed files with 809 additions and 602 deletions
|
@ -751,8 +751,7 @@ subclass::
|
|||
like::
|
||||
|
||||
@admin.display(ordering="-first_name")
|
||||
def colored_first_name(self):
|
||||
...
|
||||
def colored_first_name(self): ...
|
||||
|
||||
The ``ordering`` argument supports query lookups to sort by values on
|
||||
related models. This example includes an "author first name" column in
|
||||
|
@ -3128,8 +3127,7 @@ returns a site instance.
|
|||
from django.contrib import admin
|
||||
|
||||
|
||||
class MyAdminSite(admin.AdminSite):
|
||||
...
|
||||
class MyAdminSite(admin.AdminSite): ...
|
||||
|
||||
.. code-block:: python
|
||||
:caption: ``myproject/apps.py``
|
||||
|
@ -3467,5 +3465,4 @@ The ``staff_member_required`` decorator
|
|||
|
||||
|
||||
@staff_member_required
|
||||
def my_view(request):
|
||||
...
|
||||
def my_view(request): ...
|
||||
|
|
|
@ -40,18 +40,14 @@ API Reference
|
|||
item_geometry = ...
|
||||
|
||||
# Also a function with no arguments
|
||||
def geometry(self):
|
||||
...
|
||||
def geometry(self): ...
|
||||
|
||||
def item_geometry(self):
|
||||
...
|
||||
def item_geometry(self): ...
|
||||
|
||||
# And as a function with a single argument
|
||||
def geometry(self, obj):
|
||||
...
|
||||
def geometry(self, obj): ...
|
||||
|
||||
def item_geometry(self, item):
|
||||
...
|
||||
def item_geometry(self, item): ...
|
||||
|
||||
.. method:: geometry(obj)
|
||||
|
||||
|
|
|
@ -422,8 +422,7 @@ A dotted path to the view function to be used when an incoming request is
|
|||
rejected by the :doc:`CSRF protection </ref/csrf>`. The function should have
|
||||
this signature::
|
||||
|
||||
def csrf_failure(request, reason=""):
|
||||
...
|
||||
def csrf_failure(request, reason=""): ...
|
||||
|
||||
where ``reason`` is a short message (intended for developers or logging, not
|
||||
for end users) indicating the reason the request was rejected. It should return
|
||||
|
|
|
@ -469,8 +469,7 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
|
|||
|
||||
class Person(models.Model):
|
||||
@cached_property
|
||||
def friends(self):
|
||||
...
|
||||
def friends(self): ...
|
||||
|
||||
Note that as the method is now a property, in Python code it will need to
|
||||
be accessed appropriately::
|
||||
|
@ -552,8 +551,7 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
|
|||
|
||||
# Or more succinctly:
|
||||
@keep_lazy(str)
|
||||
def fancy_utility_function(s, *args, **kwargs):
|
||||
...
|
||||
def fancy_utility_function(s, *args, **kwargs): ...
|
||||
|
||||
The ``keep_lazy()`` decorator takes a number of extra arguments (``*args``)
|
||||
specifying the type(s) that the original function can return. A common
|
||||
|
@ -578,14 +576,12 @@ https://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004
|
|||
|
||||
# Our previous example was:
|
||||
@keep_lazy(str)
|
||||
def fancy_utility_function(s, *args, **kwargs):
|
||||
...
|
||||
def fancy_utility_function(s, *args, **kwargs): ...
|
||||
|
||||
|
||||
# Which can be rewritten as:
|
||||
@keep_lazy_text
|
||||
def fancy_utility_function(s, *args, **kwargs):
|
||||
...
|
||||
def fancy_utility_function(s, *args, **kwargs): ...
|
||||
|
||||
``django.utils.html``
|
||||
=====================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue