summaryrefslogtreecommitdiff
path: root/django/db/migrations/serializer.py
AgeCommit message (Collapse)Author
2025-11-03Fixed #36695 -- Fixed handling of parameterized generics in migration ↵Augusto Pontes
serialization. Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
2025-10-18Fixed #21961 -- Added support for database-level delete options for ForeignKey.Mariusz Felisiak
Thanks Simon Charette for pair programming. Co-authored-by: Nick Stefan <NickStefan12@gmail.com> Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com> Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-07-23Refs #36500 -- Rewrapped long docstrings and block comments via a script.django-bot
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
2025-05-13Fixed #36383 -- Improved migration serialization for functools.partial objects.Adam Johnson
2025-05-13Refs #36383 -- Extended DeconstructibleSerializer to support non-identifier ↵Adam Johnson
keyword arguments. In Python, keyword arguments must normally be valid identifiers (i.e., variable names that follow Python's naming rules). However, Python dicts can have keys that aren't valid identifiers, like "foo-bar" or "123foo". This commit ensures that keyword arguments that are nt valid identifiers, are properly handled when deconstructing an object.
2025-05-13Refs #36383, #26151 -- Corrected spelling of DeconstructibleSerializer.Adam Johnson
"Deconstructible" is the spelling that Django has settled on, such as for `django.utils.deconstruct`. This commit normalizes a previously-inconsistent class to match the rest of the codebase.
2025-03-31Fixed #36265 -- Added support for serialization of ZoneInfo instances in ↵Song Junho
migrations.
2025-02-18Refs #36005 -- Used datetime.UTC alias instead of datetime.timezone.utc.Mariusz Felisiak
datetime.UTC was added in Python 3.11.
2025-01-20Fixed #36005 -- Dropped support for Python 3.10 and 3.11.Mariusz Felisiak
2023-11-28Refs #34822, Refs #34986 -- Fixed migrations serializer support for ↵Nick Pope
functools.lru_cache(). It turns out that `functools._lru_cache_wrapper` is only a class when CPython's _functools C module provides it, otherwise it is a function. PyPy also provides it as a function.
2023-09-13Fixed #34822 -- Added support for serializing functions decorated with ↵Nick Pope
functools.lru_cache in migrations. `@functools.cache` and `@functools.lru_cache` return an object of type `functools._lru_cache_wrapper` which prevented the migrations serializer from working. Simply using the existing `FunctionTypeSerializer` for this additional type works as expected.
2023-07-18Fixed #34716 -- Fixed serialization of nested class methods in migrations.Nicolò Intrieri
Co-authored-by: Nicolò <nicolo.intrieri@spinforward.it>
2023-07-12Fixed #34697 -- Fixed non-deterministic order of dependencies and ↵Yury V. Zaytsev
sets/frozensets in migrations. Co-authored-by: Dakota Hawkins <dakotahawkins@gmail.com>
2023-01-18Refs #34233 -- Used types.NoneType.Nick Pope
Available since Python 3.10 where it was reintroduced.
2022-08-25Fixed #33916 -- Added support for serialization of enum.Flag in migrations.Willem Van Onsem
2022-03-23Refs #32365 -- Made migration writer use datetime.timezone.utc.Carlton Gibson
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-09-16Fixed #32365 -- Made zoneinfo the default timezone implementation.Carlton Gibson
Thanks to Adam Johnson, Aymeric Augustin, David Smith, Mariusz Felisiak, Nick Pope, and Paul Ganssle for reviews.
2021-07-01Fixed #32893 -- Fixed serialization of models.Model class in migrations.abhiabhi94
Migrations assumed that an import of the models.Model class must already be included when it's serialized, but for models with only custom fields this was not necessarily the case. Thanks Jaap Joris Vens for the report.
2020-06-24Fixed #31529 -- Added support for serialization of pathlib.Path/PurePath and ↵Nick Pope
os.PathLike in migrations.
2019-11-25Fixed #27914 -- Fixed serialization of nested classes in migrations.John Bowen
2019-10-03Refs #27914 -- Fixed serialization of nested enum.Enum classes in migrations.Hasan Ramezani
2019-09-30Fixed #30774 -- Made serialization in migrations use members names for Enums.Hasan Ramezani
2019-09-04Fixed #27910 -- Added enumeration helpers for use in Field.choices.Shai Berger
These classes can serve as a base class for user enums, supporting translatable human-readable names, or names automatically inferred from the enum member name. Additional properties make it easy to access the list of names, values and display labels. Thanks to the following for ideas and reviews: Carlton Gibson, Fran Hrženjak, Ian Foote, Mariusz Felisiak, Shai Berger. Co-authored-by: Shai Berger <shai@platonix.com> Co-authored-by: Nick Pope <nick.pope@flightdataservices.com> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-04-14Fixed #30350 -- Prevented recreation of migration for operations with a ↵Florian Apolloner
range object. Thanks to Mariusz Felisiak for helping with the patch.
2019-02-06Fixed #30159 -- Removed unneeded use of OrderedDict.Nick Pope
Dicts preserve order since Python 3.6.
2019-01-11Refs #29738 -- Allowed registering serializers with MigrationWriter.can
2019-01-11Moved django.db.migrations.writer.SettingsReference to django.conf.Tim Graham
Reduces the possibility of circular imports.
2018-10-11Fixed #29814 -- Added support for NoneType serialization in migrations.Patrik Sletmo
2018-07-27Fixed #29595 -- Allowed using timedelta in migrations questioner.Tim Graham
Refs #29600 -- Removed usage of django.utils.datetime_safe in migrations.
2018-06-28Fixed #29514 -- Reverted "Used datetime.timezone.utc instead of pytz.utc for ↵Tim Graham
better performance." This reverts commit 27ca5ce19f5f184018a61611c1bc319113b1d107 due to a regression.
2018-03-20Used datetime.timezone.utc instead of pytz.utc for better performance.Sergey Fedoseev
2018-02-05Refs #28814 -- Imported from collections.abc to fix Python 3.7 deprecation ↵Raymond Hettinger
warnings. https://bugs.python.org/issue25988
2017-12-11Fixed #28909 -- Simplified code using tuple/list/set/dict unpacking.Nick Pope
2017-12-06Fixed #28870 -- Added support for functools.partialmethod serialization in ↵Sergey Fedoseev
migrations.
2017-11-13Used BaseSimpleSerializer for serializing str and bytes in migrations.Sergey Fedoseev
Follow up to c716fe87821df00f9f03ecc761c914d1682591a2.
2017-05-18Fixed #28152 -- Made migrations serialize sets as set literals rather than ↵Jon Dufresne
set().
2017-04-27Refs #27795 -- Replaced many force_text() with str()Claude Paroz
Thanks Tim Graham for the review.
2017-01-25Refs #23919 -- Removed misc Python 2/3 references.Tim Graham
2017-01-25Refs #23919 -- Replaced super(ClassName, self) with super().chillaranand
2017-01-21Refs #23919 -- Removed misc references to Python 2.Tim Graham
2017-01-21Refs #23919 -- Removed re.U and re.UNICODE (default on Python 3).Mariusz Felisiak
2017-01-19Refs #23919 -- Removed enum ImportError handling for Python 2.Tim Graham
2017-01-19Refs #23919 -- Stopped inheriting from object to define new style classes.Simon Charette
2017-01-18Refs #23919 -- Removed most of remaining six usageClaude Paroz
Thanks Tim Graham for the review.
2017-01-18Refs #23919 -- Removed six.<various>_types usageClaude Paroz
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18Refs #23919 -- Removed six.PY2/PY3 usageClaude Paroz
Thanks Tim Graham for the review.
2017-01-18Refs #23919 -- Removed encoding preambles and future importsClaude Paroz
2016-11-06Fixed #27378 -- Added support for serialization of uuid.UUID in migrations.Maxime Lorant
Thanks Yuriy Korobko for the initial patch and Tobias McNulty for review.
2016-08-30Fixed #27081 -- Allowed migrations to serialize methods on pypy.Tim Graham