summaryrefslogtreecommitdiff
path: root/django/contrib/contenttypes
AgeCommit message (Collapse)Author
2026-04-07Fixed CVE-2026-4277 -- Checked add permissions in GenericInlineModelAdmin.Jacob Walls
Edit permissions were still checked as part of ordinary form validation, but because GenericInlineModelAdmin overrides get_formset(), it lacked InlineModelAdmin's dynamic DeleteProtectedModelForm.has_changed() logic for checking permissions server-side, leaving the add case unaddressed. This change reimplements the relevant part of InlineModelAdmin.get_formset(). Thanks N05ec@LZU-DSLab for the report, and Natalia Bidart, Markus Holtermann, and Simon Charette for reviews.
2026-03-11Refs #28455 -- Avoided QuerySet cloning for Prefetch() when queryset is not ↵Keryn Knight
provided. Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2026-03-11Refs #28455 -- Avoided QuerySet cloning in simple prefetch_related() usages.Keryn Knight
manager.get_queryset() always returns freshly instantiated per-instance QuerySet which doesn't need subsequent cloning. Based on work originally done by Anssi Kääriäinen and Tim Graham.
2026-02-25Fixed #36839 -- Warned when model renames encounter conflicts from stale ↵AbhimanyuGit2507
ContentTypes.
2026-02-21Fixed #36935 -- Added fallback in ContentType.app_labeled_name when ↵Marco Aurélio da Rosa Haubrich
model_class() is None. Updated ContentType.app_labeled_name to include the app_label in its string representation. This removed ambiguity for content types whose models were not present in the current codebase (for example, when multiple applications share the same database). Adjusted related tests to reflect the new representation.
2025-12-02Updated translations from Transifex.Natalia
Forwardport of 00575b79312c719a6b37035067095e2d679bb5d7 from stable/6.0.x.
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-10-16Refs #28586 -- Copied fetch modes to related objects.Adam Johnson
This change ensures that behavior and performance remain consistent when traversing relationships.
2025-10-16Fixed #28586 -- Added model field fetch modes.Adam Johnson
May your database queries be much reduced with minimal effort. co-authored-by: Andreas Pelme <andreas@pelme.se> co-authored-by: Simon Charette <charette.s@gmail.com> co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
2025-09-18Refs #28586 -- Split descriptor from GenericForeignKey.Adam Johnson
This makes GenericForeignKey more similar to other fields which act as descriptors, preparing it to add “fetcher protocol” support in a clear and consistent way.
2025-09-18Updated translations from Transifex.Natalia
Forwardport of 2a2936c3e6444a0f37156773ca405cedaf28dea7 from stable/5.2.x.
2025-08-16Refs #31123 -- Simplified create_contentypes().Nick Pope
Since 142ab6846ac09d6d401e26fc8b6b988a583ac0f5 get_contenttypes_and_models() function was only used in this module and we only needed the model names, not the content type objects themselves.
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-06-11Removed default value for app_configs in system check functions.Adam Johnson
The documentation[0] encourages users to write functions without a default for `app_configs`, and checks are always passed the argument. [0] https://docs.djangoproject.com/en/5.2/topics/checks/
2025-06-03Fixed #36060 -- Prevented IntegrityError in bulk_create() with ↵myoungjinGo-BE
order_with_respect_to.
2025-04-02Fixed #36267 -- Fixed contenttypes shortcut() view crash with an invalid ↵Ahmed Nassar
object_id for a UUIDField pk.
2025-03-31Updated translations from Transifex.Sarah Boyce
Forwardport of cc31b389a11559396fc039511c0dc567d9ade469 from stable/5.2.x.
2025-03-26Fixed #34819 -- Made GenericForeignKey prefetching use matching pk ↵Clifford Gama
representations. Ensured that rel_obj_attr and instance_attr return matching (pk, cls) tuples in GenericForeignKey.get_prefetch_queryset(), preventing mismatches when prefetching related objects where pk and get_prep_value() differ. Using value_to_string() also makes this code compatible with composite primary keys.
2025-02-03Fixed #36135 -- Fixed reverse GenericRelation prefetching.Simon Charette
The get_(local|foreign)_related_value methods of GenericRelation must be reversed because it defines (from|to)_fields and associated related_fields in the reversed order as it's effectively a reverse GenericForeignKey itself. The related value methods must also account for the fact that referenced primary key values might be stored as a string on the model defining the GenericForeignKey but as integer on the model defining the GenericRelation. This is achieved by calling the to_python method of the involved content type in get_foreign_related_value just like GenericRelatedObjectManager does. Lastly reverse many-to-one manager's prefetch_related_querysets should use set_cached_value instead of direct attribute assignment as direct assignment might are disallowed on ReverseManyToOneDescriptor descriptors. This is likely something that was missed in f5233dc (refs #32511) when the is_cached guard was added. Thanks 1xinghuan for the report.
2025-01-15Refs #33651 -- Removed Prefetch.get_current_queryset() and ↵Sarah Boyce
get_prefetch_queryset() per deprecation timeline.
2024-10-07Updated translations from Transifex.nessita
Forwardport of e245f62d0052d7b15fa2a60926d59eeeefee9be1 from stable/5.1.x.
2024-09-09Refs #373 -- Added Model._is_pk_set() abstraction to check if a Model's PK ↵Csirmaz Bendegúz
is set.
2024-08-07Updated translations from Transifex.Natalia
Forwardport of 380c6e6ddd7890fbe65826873579ef6e3af0c07d from stable/5.1.x.
2024-06-24Fixed #35545, Refs #32833 -- Fixed ContentTypeManager.get_for_models() crash ↵Sarah Boyce
in CreateModel migrations. Thank you to Csirmaz Bendegúz for the report and Simon Charettes for the review.
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-05-10Fixed #35429 -- Added argparse choices to --database options.SaJH
2024-05-04Fixed #35426 -- Updated querysets to be a required argument of GenericPrefetch.sobolevn
2024-02-20Fixed #35236 -- Used Field.attname/column attributes instead of ↵Adam Johnson
get_attname()/get_attname_column().
2024-02-19Fixed #35224 -- Made GenericForeignKey inherit from Field.Adam Johnson
2024-02-05Fixed #16281 -- Fixed ContentType.get_object_for_this_type() in a multiple ↵Ben Cail
database setup.
2024-01-29Updated translations from Transifex.Claude Paroz
Forwardport of 3cc35aafabb1523c39332ee83e769b085ed3d923 from stable/5.0.x.
2024-01-08Fixed #33481 -- Clarified remove_stale_contenttypes data loss warning.syed waheed
2023-12-04Updated translations from Transifex.Natalia
Forwardport of 8e1b820fa10d16664beb5d1ca2f5671891da1704 from stable/5.0.x.
2023-09-18Fixed #33651 -- Added support for prefetching GenericForeignKey.Clément Escolano
Co-authored-by: revanthgss <revanthgss@almabase.com> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2023-09-08Fixed #34816 -- Fixed GenericForeignKey crash when checking cache for ↵Oguzhan Akan
primary keys with different types.
2023-04-03Updated translations from Transifex.Mariusz Felisiak
Forwardport of fa687719321329f4e5017b7fc1b8cadae3c63c32 from stable/4.2.x.
2023-03-09Fixed #33985 -- Used app_config.verbose_name in ContentType.__str__().Hrushikesh Vaidya
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-20Added short description to remove_stale_contenttypes command.touhf
2022-12-20Updated translations from Transifex.Mariusz Felisiak
Updated Bulgarian, Esperanto, Hungarian, Japanese, Macedonian, Persian, Portuguese (Brazil), Russian, Spanish, and Turkmen translations. Forwardport of 46b28bbe151282e9198b719d00f84b48c92606ba from stable/4.1.x.
2022-11-18Fixed #26261 -- Fixed queryset crash when excluding reverse GenericRelation.roman_p
Thanks Amir Hadi for the report.
2022-11-09Fixed #34135 -- Added async-compatible interface to related managers.Jon Janzen
2022-11-08Fixed #34139 -- Fixed acreate(), aget_or_create(), and aupdate_or_create() ↵Jon Janzen
methods for related managers. Bug in 58b27e0dbb3d31ca1438790870b2b51ecdb10500.
2022-11-04Fixed #27654 -- Propagated alters_data attribute to callables overridden in ↵LightDiscord
subclasses. Thanks Shai Berger and Adam Johnson for reviews and the implementation idea.
2022-10-10Fixed #32833 -- Fixed ContentTypeManager.get_for_models() crash when using ↵Sarah Boyce
in migrations. Co-authored-by: Heraldo Lucena <23155511+HMaker@users.noreply.github.com>
2022-09-30Fixed #33984 -- Reverted "Fixed #32980 -- Made models cache related managers."Mariusz Felisiak
This reverts 4f8c7fd9d91b35e2c2922de4bb50c8c8066cbbc6 and adds two regression tests: - test_related_manager_refresh(), and - test_create_copy_with_m2m(). Thanks joeli for the report.
2022-08-03Updated translations from Transifex.Mariusz Felisiak
This also fixes related i18n tests. Forwardport of a3bab9332416f655c6ae0fa306c94f7f52e7398d from stable/4.1.x. Co-authored-by: Claude Paroz <claude@2xlibre.net>
2022-07-31Fixed warnings per flake8 5.0.0.Mariusz Felisiak
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-03-15Removed unnecessary _connector from Q construction in get_for_models().Mariusz Felisiak
Q._connector defaults to Q.AND. Follow up to 859a87d873ce7152af73ab851653b4e1c3ffea4c.