summaryrefslogtreecommitdiff
path: root/django/db/models/base.py
AgeCommit message (Collapse)Author
2019-03-22[2.2.x] Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of ↵Matthias Kestenholz
lazy strings. Reverted cc79c7ee637e65c8da27e56d746c87903d5ec901. Backport of ea071870f943c23a8eaf36dfcdf382afd6478fd1 from master.
2019-03-14[2.2.x] Fixed #30254 -- Allowed model metaclasses to access the attribute ↵Matt Westcott
dict in __init__(). Regression in a68ea231012434b522ce45c513d84add516afa60. Backport of 58ad030d05fa50cfed327368ab61defca3303e02 from master.
2019-01-12Fixed #30062 -- Added support for unique conditional constraints.Paveł Tyślacki
2018-12-22Fixed #29970, #30041 -- Made ModelBase.__new__() pass attrs without ↵Sergey Fedoseev
contribute_to_class() to type.__new__().
2018-11-13Fixed #29641 -- Added support for unique constraints in Meta.constraints.Simon Charette
This constraint is similar to Meta.unique_together but also allows specifying a name. Co-authored-by: Ian Foote <python@ian.feete.org>
2018-10-28Fixed #29896 -- Fixed incorrect Model.save() cache relation clearing for ↵Tim Graham
foreign keys that use to_field. Regression in ee49306176a2d2f1751cb890bd607d42c7c09196.
2018-10-17Fixed #21171 -- Avoided starting a transaction when a single (or atomic ↵Florian Apolloner
queries) are executed. Checked the following locations: * Model.save(): If there are parents involved, take the safe way and use transactions since this should be an all or nothing operation. If the model has no parents: * Signals are executed before and after the previous existing transaction -- they were never been part of the transaction. * if `force_insert` is set then only one query is executed -> atomic by definition and no transaction needed. * same applies to `force_update`. * If a primary key is set and no `force_*` is set Django will try an UPDATE and if that returns zero rows it tries an INSERT. The first case is completly save (single query). In the second case a transaction should not produce different results since the update query is basically a no-op then (might miss something though). * QuerySet.update(): no signals issued, single query -> no transaction needed. * Model/Collector.delete(): This one is fun due to the fact that is does many things at once. Most importantly though: It does send signals as part of the transaction, so for maximum backwards compatibility we need to be conservative. To ensure maximum compatibility the transaction here is removed only if the following holds true: * A single instance is being deleted. * There are no signal handlers attached to that instance. * There are no deletions/updates to cascade. * There are no parents which also need deletion.
2018-08-31Refs #27795 -- Removed force_text() in Model._get_FIELD_display().Jon Dufresne
2018-08-22Fixed #26352 -- Made system check allow ManyToManyField to target the same ↵Simon Willison
model if through_fields differs.
2018-08-20Fixed #29625 -- Made Model.refresh_from_db() clear prefetch related caches.Ming Qin
2018-08-10Fixed #29653 -- Fixed missing related_query_name reverse accessor if ↵Ramiro Morales
GenericRelation is declared on an abstract base model. Regression in 4ab027b94409e6415b774797bf9d3593da9d9ea8. Thanks Lauri Kainulainen for the report.
2018-07-20Fixed #29568 -- Prevented unnecessary UPDATE queries creating child models.François Dupayrat
2018-07-10Fixed #11964 -- Added support for database check constraints.Ian Foote
2018-06-25Refs #29516 -- Reverted inadvertent change in Model.__init__().Tim Graham
2018-06-25Fixed #29517 -- Rephrased error message when passing incorrect kwarg to ↵Federico Bond
model constructor
2018-05-03Refs #29358 -- Corrected wording in primary key check message.Carlton Gibson
2018-05-03Fixed #29358 -- Added a system check to prohibit models with more than one ↵Hasan Ramezani
primary_key field.
2018-03-12Fixed #28988 -- Fixed queries when a GenericRelation is used with ↵robwa
multi-table inheritance.
2018-01-31Fixed #29093 -- Simplified a few lines in ModelBase.__new__().Дилян Палаузов
2018-01-30Fixed #29076 -- Made Model.refresh_from_db() clear cached relationships even ↵Jon Dufresne
if the related id doesn't change.
2018-01-03Fixed #28982 -- Simplified code with and/or.Дилян Палаузов
2018-01-03Fixed #28867 -- Added system check for a model property that clashes with a ↵shanghui
related field accessor.
2018-01-02Fixed #28974 -- Made refresh_from_db() hint routers about its instance.Simon Charette
2017-12-30Fixed #28918 -- Fixed Model.refresh_from_db() for instances hidden by the ↵Tim Graham
default manager.
2017-12-27Fixed #28714 -- Added system checks for invalid model field names in ↵hui shang
Meta.indexes. Thanks Gabriel for the report and Adam Johnson for the review.
2017-12-26Fixed #28930 -- Simplified code with any() and all().Дилян Палаузов
2017-12-11Fixed #28909 -- Simplified code using tuple/list/set/dict unpacking.Nick Pope
2017-12-04Fixed #28860 -- Removed unnecessary len() calls.Дилян Палаузов
2017-11-09Fixed #27710 -- Made Model.save() invalidate cached, stale relations after a ↵Paulo
primary key assignment.
2017-10-13Fixed #28695 -- Allowed models to use __init_subclass__().k
2017-10-13Refs #28575 -- Removed unnecessary code for model exception pickling.Simon Charette
Setting __qualname__ is sufficient for pickling of DoesNotExist and and MultipleObjectsReturned to work correctly.
2017-10-13Refs #28575 -- Allowed pickling Model.DoesNotExist and ↵Rachel Tobin
MultipleObjectsReturned classes.
2017-10-12Fixed #27846 -- Made Model.refresh_from_db() clear cached relations.Paulo
2017-09-18Fixed #28597 -- Fixed crash with the name of a model's autogenerated primary ↵Mariusz Felisiak
key in an Index's fields.
2017-09-06Refs #23919 -- Replaced usage of django.utils.functional.curry() with ↵Sergey Fedoseev
functools.partial()/partialmethod().
2017-09-05Fixed #28335 -- Allowed query expressions in Meta.ordering.Dima Kudosh
2017-08-11Refs #28459 -- Optimized ModelState instantiation.Sergey Fedoseev
2017-08-11Fixed #28456 -- Allowed customizing Model pickling by overriding __getstate__().Nerl~
2017-08-10Refs #16043 -- Refactored internal fields value cache.Paulo
* Removed all hardcoded logic for _{fieldname}_cache. * Added an internal API for interacting with the field values cache. Thanks carljm and MarkusH for support.
2017-08-02Refs #28459 -- Improved performance of Model.from_db() when fields are deferred.Sergey Fedoseev
2017-07-31Avoided creating temporary lists for obtaining the first item.Sergey Fedoseev
2017-06-11Refs #23919 -- Removed support for broken Model.__str__() in Model.__repr__().Tim Graham
Returning invalid bytestrings in __str__() is unlikely in Python 3.
2017-06-09Fixed #27953 -- Added instance's pk to Model.__str__().Collin Anderson
2017-06-08Fixed #28282 -- Fixed class-based indexes name for models that only inherit ↵Jon Dufresne
Model.
2017-06-05Replaced Model._get_pk_val() with pk property.Tim Graham
Model.pk was added after _get_pk_val() and many places weren't simplified.
2017-06-01Refs #23968 -- Removed unnecessary lists, generators, and tuple calls.Jon Dufresne
2017-05-27Fixed #28249 -- Removed unnecessary dict.keys() calls.Jon Dufresne
iter(dict) is equivalent to iter(dict.keys()).
2017-04-27Replaced set |= operator with update() to avoid temporary set.Jon Dufresne
2017-03-21Fixed #27915 -- Allowed Meta.indexes to be defined in abstract models.Tim Graham
Thanks Markus Holtermann for review.
2017-03-04Refs #27795 -- Removed unneeded force_text callsClaude Paroz
Thanks Tim Graham for the review.