mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[5.0.x] Applied Black's 2024 stable style.
https://github.com/psf/black/releases/tag/24.1.0
Backport of 305757aec1 from main
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Helper functions for creating Form classes from Django models
|
||||
and database field objects.
|
||||
"""
|
||||
|
||||
from itertools import chain
|
||||
|
||||
from django.core.exceptions import (
|
||||
@@ -830,9 +831,12 @@ class BaseModelFormSet(BaseFormSet, AltersData):
|
||||
)
|
||||
# Reduce Model instances to their primary key values
|
||||
row_data = tuple(
|
||||
d._get_pk_val() if hasattr(d, "_get_pk_val")
|
||||
# Prevent "unhashable type: list" errors later on.
|
||||
else tuple(d) if isinstance(d, list) else d
|
||||
(
|
||||
d._get_pk_val()
|
||||
if hasattr(d, "_get_pk_val")
|
||||
# Prevent "unhashable type: list" errors later on.
|
||||
else tuple(d) if isinstance(d, list) else d
|
||||
)
|
||||
for d in row_data
|
||||
)
|
||||
if row_data and None not in row_data:
|
||||
|
||||
@@ -101,9 +101,11 @@ class Media:
|
||||
|
||||
def render_js(self):
|
||||
return [
|
||||
path.__html__()
|
||||
if hasattr(path, "__html__")
|
||||
else format_html('<script src="{}"></script>', self.absolute_path(path))
|
||||
(
|
||||
path.__html__()
|
||||
if hasattr(path, "__html__")
|
||||
else format_html('<script src="{}"></script>', self.absolute_path(path))
|
||||
)
|
||||
for path in self._js
|
||||
]
|
||||
|
||||
@@ -113,12 +115,14 @@ class Media:
|
||||
media = sorted(self._css)
|
||||
return chain.from_iterable(
|
||||
[
|
||||
path.__html__()
|
||||
if hasattr(path, "__html__")
|
||||
else format_html(
|
||||
'<link href="{}" media="{}" rel="stylesheet">',
|
||||
self.absolute_path(path),
|
||||
medium,
|
||||
(
|
||||
path.__html__()
|
||||
if hasattr(path, "__html__")
|
||||
else format_html(
|
||||
'<link href="{}" media="{}" rel="stylesheet">',
|
||||
self.absolute_path(path),
|
||||
medium,
|
||||
)
|
||||
)
|
||||
for path in self._css[medium]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user