summaryrefslogtreecommitdiff
path: root/django/db/models/fields/related.py
AgeCommit message (Collapse)Author
2026-04-02Fixed #36973 -- Made fields.E348 check detect further clashes between ↵Clifford Gama
managers and related_names. Clashes were only detected for self-referential relationships, i.e. ForeignKey("self"). Refs #22977. Bug in 6888375c53476011754f778deabc6cdbfa327011. Thanks JaeHyuckSa for the thorough review!
2025-11-23Refs #21961 -- Added DatabaseFeatures.supports_on_delete_db_(cascade/null) ↵Tim Graham
feature flags. Needed on MongoDB. Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@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-09-22Fixed #35453 -- Made ManyToManyField.concrete False.Ryan P Kilby
ManyToManyField was already excluded from fields, concrete_fields, and local_concrete_fields in Options.
2025-08-05Fixed #36530 -- Extended fields.E347 to check for ManyToManyField involving ↵jkhall81
CompositePrimaryKey on either side. Thanks to Jacob Walls for the report.
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-03-31Fixed #22977 -- Added system check for clashing managers and reverse related ↵Anthony Joseph
fields. With thanks to Konrad Świat, Loïc Bistuer, Russell Keith-Magee, and Mariusz Felisiak. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2025-03-28Fixed #36239 -- Fixed a crash in ManyToManyField.through_fields check when ↵saJaeHyukc
to model is invalid. Signed-off-by: saJaeHyukc <wogur981208@gmail.com>
2025-02-06Fixed #36061 -- Added migration support for ManyToManyField.through_fields.brian
Added through_fields support to ManyToManyField.deconstruct. Thanks to Simon Charette for pointers and the review.
2025-01-15Refs #16055 -- Removed get_joining_columns()/get_reverse_joining_columns() ↵Sarah Boyce
methods per deprecation timeline.
2025-01-02Fixed #36034 -- Added system check for ↵Mariusz Felisiak
ForeignKey/ForeignObject/ManyToManyField to CompositePrimaryKeys.
2024-11-29Fixed #373 -- Added CompositePrimaryKey.Bendeguz Csirmaz
Thanks Lily Foote and Simon Charette for reviews and mentoring this Google Summer of Code 2024 project. Co-authored-by: Simon Charette <charette.s@gmail.com> Co-authored-by: Lily Foote <code@lilyf.org>
2024-09-09Refs #373 -- Added Model._is_pk_set() abstraction to check if a Model's PK ↵Csirmaz Bendegúz
is set.
2024-08-28Refs #16055 -- Adjusted deprecation warning stacklevel in ↵Simon Charette
get_joining_columns()/get_reverse_joining_columns().
2024-07-09Fixed #35580 -- Allowed related fields referencing auto-created through models.jason_bruce
2024-07-04Fixed #35569 -- Improved wording of invalid ForeignKey error message.Jacob Walls
2024-05-21Fixed #35405 -- Converted get_cache_name into a cached property in ↵Adam Johnson
FieldCacheMixin. FieldCacheMixin is used by related fields to track their cached values. This work migrates get_cache_name() to be a cached property to optimize performance by reducing unnecessary function calls when working with related fields, given that its value remains constant. Co-authored-by: Simon Charette <charette.s@gmail.com> Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-03-11Fixed #35285 -- Optimized ForeignObject._check_unique_target().Adam Johnson
2024-03-04Fixed #35266 -- Deferred formatting in RelatedField._check_clashes().Adam Johnson
2024-02-19Refs #28011 -- Removed ForeignObjectRel.is_hidden().Adam Johnson
2024-02-19Fixed #35230 -- Added cached ForeignObjectRel.accessor_name.Adam Johnson
2023-09-19Simplified ForeignObject.resolve_related_fields() a bit.Lily Foote
2023-04-18Refs #16055 -- Deprecated ↵David Wobrock
get_joining_columns()/get_reverse_joining_columns() methods.
2023-04-18Fixed #16055 -- Fixed crash when filtering against char/text GenericRelation ↵David Wobrock
relation on PostgreSQL.
2023-03-14Refs #28329 -- Fixed Cast() with ForeignKey to integer fields on MySQL.David Wobrock
2023-02-01Refs #33476 -- Applied Black's 2023 stable style.David Smith
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-01-18Refs #34233 -- Used @functools.cache.Nick Pope
Python 3.9+ supports @functools.cache as an alias for @functools.lru_cache(maxsize=None).
2022-12-28Fixed #18468 -- Added support for comments on columns and tables.kimsoungryoul
Thanks Jared Chung, Tom Carrick, David Smith, Nick Pope, and Mariusz Felisiak for reviews. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com> Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-11-18Removed unnecessary ForeignKey.get_reverse_path_info().Mariusz Felisiak
get_reverse_path_info() is already inherited from ForeignObject.
2022-10-31Used more augmented assignment statements.Nick Pope
Identified using the following command: $ git grep -I '\(\<[_a-zA-Z0-9]\+\>\) *= *\1 *[-+/*^%&|<>@]'
2022-09-02Fixed #29799 -- Allowed registering lookups per field instances.Allen Jonathan David
Thanks Simon Charette and Mariusz Felisiak for reviews and mentoring this Google Summer of Code 2022 project.
2022-07-27Refs #32948, Refs #32946 -- Used Q.create() internally for dynamic Q() objects.Nick Pope
Node.create() which has a compatible signature with Node.__init__() takes in a single `children` argument rather than relying in unpacking *args in Q.__init__() which calls Node.__init__(). In addition, we were often needing to unpack iterables into *args and can instead pass a list direct to Node.create().
2022-05-02Fixed #33413 -- Made migrations propage collations to related fields.David Wobrock
2022-04-22Refs #31223 -- Added __class_getitem__() to ForeignKey.Collin Anderson
2022-02-16Fixed #33515 -- Prevented recreation of migration for ManyToManyField to ↵Mariusz Felisiak
lowercased swappable setting. Thanks Chris Lee for the report. Regression in 43289707809c814a70f0db38ca4f82f35f43dbfd. Refs #23916.
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-12-10Corrected return value of ForeignKey.db_check().Adam Johnson
Field.db_check() should return None or a SQL string. Returning [] happened to work because it’s falsey.
2021-11-03Fixed #32996 -- Cached PathInfos on relations.Keryn Knight
PathInfo values are ostensibly static over the lifetime of the object for which they're requested, so the data can be memoized, quickly amortising the cost over the process' duration.
2021-10-06Fixed #33131 -- Improved error messages for clashing reverse accessor names.Bernd Wechner
2021-09-09Fixed #33084 -- Removed incorrect system check for ManyToManyField with ↵Hasan Ramezani
limit_choices_to.
2021-08-06Fixed #32983 -- Added system check for redundant related_name on symmetrical ↵Nick Touran
M2M fields. Since ManyToManyFields defined with `symmetrical=True` do not add a related field to the target model, including a `related_name` argument will never do what the coder likely expects. This makes including a related_name with a symmetrical model raise a system check warning. ticket-32983
2021-07-28Refs #32946 -- Changed internal usage of dynamic Q() objects construction to ↵Keryn Knight
use non-kwargs initialization. This prefers non-kwargs construction of dynamically generated Q() objects to create a single Q() object instead of many and then combining them, where possible.
2021-07-22Fixed #32951 -- Removed Query.where_class & co.Nick Pope
Unused since 3caf957ed5eaa831a485abcb89f27266dbf3e82b.
2021-07-15Refs #32508 -- Raised Type/ValueError instead of using "assert" in ↵Daniyal
django.db.models. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2021-05-28Fixed #32676 -- Prevented migrations from rendering related field attributes ↵David Wobrock
when not passed during initialization. Thanks Simon Charette for the implementation idea.
2020-12-30Fixed #32294 -- Prevented ManyToManyField's hidden related name collisions ↵manav014
between apps.
2020-12-29Added app labels to related fields checks messages E302-E305.Mariusz Felisiak
2020-12-29Used model's Options.label where applicable.Mariusz Felisiak
Follow up to b7a3a6c9ef0a89625881b47594120bca55fa2e49.
2020-06-26Fixed #31742 -- Fixed makemigrations crash on ForeignKey to an app with ↵Mariusz Felisiak
mixed case label. Regression in 9e1b6b8a66af4c2197e5b1b41eb9dbb36e4f6502. Thanks Ignacio Santolin for the report.