150 Commits

Author SHA1 Message Date
Mariusz Felisiak
6cff020787 Applied Black's 2026 stable style.
https://github.com/psf/black/releases/tag/26.1.0
2026-01-18 21:26:56 +01:00
Jacob Walls
73c5e94521 Refs #36769 -- Raised SuspiciousOperation for unexpected nested tags in XML Deserializer.
Thanks Shai Berger and Natalia Bidart for reviews.
2026-01-12 16:38:32 -05:00
Youngkwang Yang
95394443bf Fixed #36786 -- Fixed XML serialization of None values in natural keys.
None values in natural keys were incorrectly serialized as the string
"None", causing deserialization to fail for fields like UUIDField.
2025-12-22 14:21:01 -05:00
Mariusz Felisiak
4702b36120 Fixed #27380 -- Added "raw" argument to m2m_changed signals. 2025-12-17 18:37:18 +01:00
rimi0108
93540b34d4 Fixed #35729 -- Enabled natural key serialization opt-out for subclasses.
Refactored serialization logic to allow models inheriting a natural_key()
method (e.g. AbstractBaseUser) to explicitly opt out of natural key
serialization by returning an empty tuple from the method.

Thanks Jonas Dittrich for the report.

Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
2025-12-03 15:04:52 -05:00
Shai Berger
50efb718b3 Fixed CVE-2025-64460 -- Corrected quadratic inner text accumulation in XML serializer.
Previously, `getInnerText()` recursively used `list.extend()` on strings,
which added each character from child nodes as a separate list element.
On deeply nested XML content, this caused the overall deserialization
work to grow quadratically with input size, potentially allowing
disproportionate CPU consumption for crafted XML.

The fix separates collection of inner texts from joining them, so that
each subtree is joined only once, reducing the complexity to linear in
the size of the input. These changes also include a mitigation for a
xml.dom.minidom performance issue.

Thanks Seokchan Yoon (https://ch4n3.kr/) for report.

Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2025-12-02 09:21:07 -03:00
django-bot
69a93a88ed Refs #36500 -- Rewrapped long docstrings and block comments via a script.
Rewrapped long docstrings and block comments to 79 characters + newline
using script from https://github.com/medmunds/autofix-w505.
2025-07-23 20:17:55 -03:00
Sarah Boyce
1ecf6889ca Removed double spaces after periods and within phrases. 2025-07-23 10:09:43 -03:00
Tom Carrick
8df5ce80d2 Fixed #36177 -- Added a trailing newline to JSON serializer. (#19232) 2025-03-11 08:01:06 +01:00
Mariusz Felisiak
ff3aaf036f Applied Black's 2025 stable style.
https://github.com/psf/black/releases/tag/25.1.0
2025-03-01 19:41:37 +01:00
Erica Pisani
20f9f61805 Fixed #35996 -- Fixed database serialization crash when serializing a many-to-many field that had a prefetch. 2024-12-18 10:39:20 +01:00
Mariusz Felisiak
3d508ececb Refs #21286 -- Fixed serializers tests if Pillow isn't installed. 2024-12-05 08:51:05 +01:00
Adam Zapletal
d2f2a6a6d5 Refs #21286 -- Enabled ImageField test cases in serializer data tests.
This aligns ImageField to be tested in the same way as FileField.
The commented-out test also exists for FileField and relates to #10244.
2024-12-03 15:15:16 +01:00
Sarah Boyce
d783a6f1c0 Improved assert_serializer test assertions in test.serializers. 2024-12-02 08:35:55 +01:00
Sarah Boyce
a444d2600b Used skipIf/UnlessDBFeature in test.serializers. 2024-12-02 08:35:55 +01:00
Adam Zapletal
1636912bf1 Refs #21286 -- Fixed serializer test with primary key TextField. 2024-11-28 11:45:34 +01:00
Adam Zapletal
b9aa3239ab Refs #21286 -- Fixed YAML serialization of TimeField primary key.
Handling for PyYAML not being able to serialize `datetime.time`
values is moved from `handle_field` to `_value_from_field` as only
non-primary key, non-relation fields are passed into `handle_field`.
2024-11-12 13:23:14 +01:00
SaJH
0c81775515 Refs #35727 -- Updated response.content.decode calls to use the HttpResponse.text property.
Signed-off-by: SaJH <wogur981208@gmail.com>
2024-10-16 11:52:22 +02:00
Mariusz Felisiak
1fa8493640 Refs #29522 -- Fixed serializers/fixtures test crash if PyYAML isn't installed. 2024-09-19 08:51:30 +02:00
Amir Karimi
ee5147cfd7 Fixed #29522 -- Refactored the Deserializer functions to classes.
Co-authored-by: Emad Mokhtar <emad.mokhtar@veneficus.nl>
2024-09-17 11:00:49 +02:00
Adam Zapletal
3d4fe39bac Refs #21286 -- Removed invalid commented out models and tests from serializer tests.
FileField/ImageField cannot be primary keys, so serialization support
for this case will not be implemented.

XMLField was removed in d1290b5b43.
2024-03-04 11:38:18 +01:00
Mariusz Felisiak
305757aec1 Applied Black's 2024 stable style.
https://github.com/psf/black/releases/tag/24.1.0
2024-01-26 12:45:07 +01:00
konsti
48a1929ca0 Removed unnecessary trailing commas in tests. 2023-08-22 12:42:57 +02:00
Juan Alvarez
517d3bb4dd Fixed #34779 -- Avoided unnecessary selection of non-nullable m2m fields without natural keys during serialization.
By using `select_related(None)` instead of `select_related()`, the
unnecessary joins are completely avoided. Note that the current tests
already covers the change, when the field is not `null=True`.

Regression in f9936deed1.
2023-08-19 10:29:43 +02:00
Mariusz Felisiak
f9936deed1 Fixed #34620 -- Fixed serialization crash on m2m fields without natural keys when base querysets use select_related().
Regression in 19e0587ee5.

Thanks Martin Svoboda for the report.
2023-06-04 20:49:07 +02:00
David Smith
097e3a70c1 Refs #33476 -- Applied Black's 2023 stable style.
Black 23.1.0 is released which, as the first release of the year,
introduces the 2023 stable style. This incorporates most of last year's
preview style.

https://github.com/psf/black/releases/tag/23.1.0
2023-02-01 11:04:38 +01:00
Mariusz Felisiak
b119f4329c Refs #29708 -- Removed PickleSerializer per deprecation timeline. 2023-01-17 11:49:15 +01:00
Mark Evans
19e0587ee5 Fixed #33937 -- Optimized serialization of related m2m fields without natural keys. 2022-09-05 20:23:32 +02:00
Mariusz Felisiak
8e89dfe1c2 Fixed various tests on MySQL with MyISAM storage engine. 2022-04-18 07:05:52 +02:00
Nick Pope
847f46e9bf Removed redundant QuerySet.all() calls in docs and tests.
Most QuerySet methods are mapped onto the Manager and, in general,
it isn't necessary to call .all() on the manager.
2022-02-22 10:29:38 +01:00
Mariusz Felisiak
7119f40c98 Refs #33476 -- Refactored code to strictly match 88 characters line length. 2022-02-07 20:37:05 +01:00
django-bot
9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Adam Johnson
45a42aabfa Fixed #29708 -- Deprecated PickleSerializer. 2022-01-13 13:50:20 +01:00
Daniyal Abbasi
dca4c2ff76 Refs #33012 -- Moved PickleSerializer to django.core.serializers.base and added tests. 2021-09-02 11:24:55 +02:00
Mikolaj Rybinski
8e90560aa8 Fixed #32420 -- Fixed detecting primary key values in deserialization when PK is also a FK. 2021-02-05 12:33:43 +01:00
Mariusz Felisiak
d992f4e3c2 Refs #31369 -- Removed models.NullBooleanField per deprecation timeline. 2021-01-14 17:50:04 +01:00
Ahmad A. Hussein
493b26bbfc Fixed #31888 -- Avoided module-level MySQL queries in tests. 2020-08-17 09:31:16 +02:00
Mariusz Felisiak
83f55aafdd Fixed #17653 -- Allowed using zero as AutoFields value on MySQL if NO_AUTO_VALUE_ON_ZERO SQL mode is enabled. 2020-07-20 09:48:31 +02:00
Mariusz Felisiak
78c811334c Refs #30190 -- Minor edits to JSONL serializer.
Follow up to e29637681b.
2020-06-17 07:59:40 +02:00
Ali Vakilzade
e29637681b Fixed #30190 -- Added JSONL serializer. 2020-06-16 16:51:58 +02:00
Claude Paroz
adf58311b8 Fixed #29078 -- Made serializers respect prefetch_related() for m2m fields. 2020-05-25 10:45:16 +02:00
Simon Charette
94f63b926f Refs #31395 -- Relied on setUpTestData() test data isolation in various tests. 2020-05-15 20:22:56 +02:00
Nick Pope
8f10ceaa90 Changed '%s' % value pattern to str(value). 2020-05-04 08:27:18 +02:00
Hasan Ramezani
68fc21b378 Fixed #29249 -- Made JSON and YAML serializers use Unicode by default. 2020-04-28 11:11:39 +02:00
Hasan Ramezani
8970bb4cfd Refs #29249 -- Added tests for serializing Unicode data with XML serializer. 2020-04-28 11:11:39 +02:00
Mariusz Felisiak
cf21fc9bf0 Enforced uniqueness of natural keys used in tests. 2020-04-07 10:54:19 +02:00
Hasan Ramezani
fc4f45ebdc Used assertRaisesMessage() in various tests. 2020-02-07 12:46:23 +01:00
Simon Charette
5779cc938a Fixed #31071 -- Disabled insert optimization for primary keys with defaults when loading fixtures.
Model.save_base() is called directly when loading fixtures and assumes
existing rows will be updated. Branching of "raw" allows to maintain
the optimization introduced in #29260 while supporting this edge case.

Regression in 85458e94e3.

Thanks Reupen Shah for the report.
2019-12-30 07:49:10 +01:00
Baptiste Mispelon
738e9e615d Fixed #26743 -- Fixed UnboundLocalError crash when deserializing m2m fields and value isn't iterable. 2019-12-13 11:38:09 +01:00
Caio Ariede
555bebe774 Fixed #30987 -- Added models.PositiveBigIntegerField. 2019-11-19 09:34:11 +01:00