Tim Graham
5a52d932ef
Replaced Model._get_pk_val() with pk property.
...
Model.pk was added after _get_pk_val() and many places weren't simplified.
2017-06-05 15:20:34 -04:00
Jon Dufresne
2c69824e5a
Refs #23968 -- Removed unnecessary lists, generators, and tuple calls.
2017-06-01 19:08:59 -04:00
Jon Dufresne
21046e7773
Fixed #28249 -- Removed unnecessary dict.keys() calls.
...
iter(dict) is equivalent to iter(dict.keys()).
2017-05-27 19:08:46 -04:00
Jon Dufresne
7be94e0335
Replaced set |= operator with update() to avoid temporary set.
2017-04-27 08:16:19 -04:00
Tim Graham
3d19d1428a
Fixed #27915 -- Allowed Meta.indexes to be defined in abstract models.
...
Thanks Markus Holtermann for review.
2017-03-21 10:53:21 -04:00
Claude Paroz
8346680e1c
Refs #27795 -- Removed unneeded force_text calls
...
Thanks Tim Graham for the review.
2017-03-04 18:18:21 +01:00
Anton Samarchyan
60e52a047e
Refs #27656 -- Updated django.db docstring verbs according to PEP 257.
2017-02-28 09:17:27 -05:00
Claude Paroz
c651331b34
Converted usage of ugettext* functions to their gettext* aliases
...
Thanks Tim Graham for the review.
2017-02-07 09:04:04 +01:00
Tim Graham
29f607927f
Fixed spelling of "nonexistent".
2017-02-03 08:01:45 -05:00
chillaranand
d6eaf7c018
Refs #23919 -- Replaced super(ClassName, self) with super().
2017-01-25 12:23:46 -05:00
Claude Paroz
042b7350a0
Refs #23919 -- Removed unneeded str() calls
2017-01-20 14:13:55 +01:00
Claude Paroz
dc8834cad4
Refs #23919 -- Removed unneeded force_str calls
2017-01-20 08:44:31 +01:00
Simon Charette
cecc079168
Refs #23919 -- Stopped inheriting from object to define new style classes.
2017-01-19 08:39:46 +01:00
Aymeric Augustin
eb422e476f
Refs #23919 -- Removed obsolete __ne__() methods.
...
__ne__() defaults to the opposite of __eq__() on Python 3
when it doesn't return NotImplemented.
2017-01-18 21:44:00 -05:00
Claude Paroz
2b281cc35e
Refs #23919 -- Removed most of remaining six usage
...
Thanks Tim Graham for the review.
2017-01-18 21:33:28 +01:00
Claude Paroz
7b2f2e74ad
Refs #23919 -- Removed six.<various>_types usage
...
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz
c716fe8782
Refs #23919 -- Removed six.PY2/PY3 usage
...
Thanks Tim Graham for the review.
2017-01-18 16:21:28 +01:00
Claude Paroz
f3c43ad1fd
Refs #23919 -- Removed python_2_unicode_compatible decorator usage
2017-01-18 13:44:34 +01:00
Claude Paroz
d7b9aaa366
Refs #23919 -- Removed encoding preambles and future imports
2017-01-18 09:55:19 +01:00
Tim Graham
631f4ab061
Removed Manager.use_for_related_fields and Meta.manager_inheritance_from_future.
...
Per deprecation timeline. Refs ed0ff913c6
.
2017-01-17 20:52:04 -05:00
Adam Chainz
d2a26c1a90
Optimized Model instantiation a bit.
...
* Avoid some unnecessary attribute lookups, e.g. access signals directly rather than from module
* Alias some repeat accesses inside the method to use the slightly faster local lookups
* Use tuple to iterate remaining kwargs as it's faster to construct
* Cache Field.get_default() to avoid running through all the logic on every call
* Use a cached list of the properties on the model class to avoid repeat isinstance() calls
2016-12-15 13:42:44 -05:00
Tim Graham
dd99e69fa8
Refs #27025 -- Fixed Python 3.6 deprecation warning for empty model super() calls.
...
https://bugs.python.org/issue23722
Thanks Nick Coghlan for advice and review.
2016-12-05 19:37:23 -05:00
Adam Chainz
6252fd6314
Fixed #27532 -- Deprecated Model._meta.has_auto_field
2016-11-25 13:24:11 -05:00
Adam Chainz
92bbef8b9e
Improved the way Model.save() skips the auto_field.
...
Identity comparison is quicker than isinstance(), and it avoids coupling
between Model and AutoField.
2016-11-24 06:01:36 -05:00
Quentin Fulsher
f62abfc03d
Fixed #27295 -- Added a system check to prohibit model names that start or end with an underscore or contain double underscores.
2016-11-22 10:14:10 -05:00
Adam Chainz
74742aa956
Fixed #27512 -- Removed unused code in Model.__init__().
2016-11-20 19:39:32 -05:00
Adam Chainz
9d4246419c
Refs #26207 -- Removed obsolete comments about deferred model classes.
2016-11-20 18:22:13 -05:00
Adam Chainz
cc1f6f26b6
Fixed #27514 -- Tested Model.__init__ excessive number of fields.
2016-11-20 13:21:59 -05:00
Ramin Farajpour Cami
967be82443
Fixed E305 flake8 warnings.
2016-11-14 12:30:46 -05:00
Nick Pope
f1664a2734
Replaced '__' with LOOKUP_SEP constant.
2016-10-11 11:14:06 -04:00
Akshesh
6a8372e6ec
Fixed #26808 -- Added Meta.indexes for class-based indexes.
...
* Added the index name to its deconstruction.
* Added indexes to sqlite3.schema._remake_table() so that indexes
aren't dropped when _remake_table() is called.
Thanks timgraham & MarkusH for review and advice.
2016-08-05 18:12:51 -04:00
Andrew Nester
baff4dd37d
Fixed #25292 -- Fixed crash in ManyToManyField.through_fields check.
2016-06-30 08:53:38 -04:00
Jon Dufresne
267dc4addd
Fixed #4136 -- Made ModelForm save empty values for nullable CharFields as NULL.
...
Previously, empty values were saved as strings.
2016-06-13 09:14:36 -04:00
Marti Raudsepp
b9ae662c97
Fixed #26620 -- Made Model.refresh_from_db() fail when passed unknown kwargs.
2016-05-18 09:27:23 -04:00
Loïc Bistuer
ed0ff913c6
Fixed #10506 , #13793 , #14891 , #25201 -- Introduced new APIs to specify models' default and base managers.
...
This deprecates use_for_related_fields.
Old API:
class CustomManager(models.Model):
use_for_related_fields = True
class Model(models.Model):
custom_manager = CustomManager()
New API:
class Model(models.Model):
custom_manager = CustomManager()
class Meta:
base_manager_name = 'custom_manager'
Refs #20932 , #25897 .
Thanks Carl Meyer for the guidance throughout this work.
Thanks Tim Graham for writing the docs.
2016-05-17 12:07:22 +07:00
Loïc Bistuer
3a47d42fa3
Fixed #20932 , #25897 -- Streamlined manager inheritance.
2016-05-17 02:29:22 +07:00
Aron Podrigal
85ef98dc6e
Fixed #24305 -- Allowed overriding fields on abstract models.
...
Fields inherited from abstract base classes may be overridden like
any other Python attribute. Inheriting from multiple models/classes
with the same attribute name will follow the MRO.
2016-05-16 07:32:21 -04:00
Michal Petrucha
8a47ba679d
Refs #16508 -- Made Model.__init__() aware of virtual fields.
...
It's no longer necessary for GenericForeignKey (and any other virtual fields)
to intercept the field's values using the pre_init signal.
2016-05-03 09:06:26 -04:00
Anssi Kääriäinen
7f51876f99
Fixed #26207 -- Replaced dynamic classes with non-data descriptors for deferred instance loading.
2016-04-29 13:06:32 -04:00
Michal Petrucha
c339a5a6f7
Refs #16508 -- Renamed the current "virtual" fields to "private".
...
The only reason why GenericForeignKey and GenericRelation are stored
separately inside _meta is that they need to be cloned for every model
subclass, but that's not true for any other virtual field. Actually,
it's only true for GenericRelation.
2016-04-13 10:10:53 -04:00
Tim Graham
df8d8d4292
Fixed E128 flake8 warnings in django/.
2016-04-08 09:51:06 -04:00
Tim Graham
2cd2d18851
Fixed W503 flake8 warnings.
2016-04-04 17:14:26 -04:00
Akshesh
49f95cc0a0
Fixed #11560 -- Allowed proxy model multiple-inheritance from the same concrete base model.
2016-03-30 13:06:27 -04:00
Simon Charette
67cf5efa31
Fixed #26413 -- Fixed a regression with abstract model inheritance and explicit parent links.
...
Thanks Trac alias trkjgrdg for the report and Tim for investigation and review.
2016-03-28 21:11:37 -04:00
Tim Graham
004ba0f99e
Removed unneeded hint=None/obj=None in system check messages.
2016-02-12 13:01:25 -05:00
Tim Graham
10a162809f
Refs #24007 -- Removed an apps.populate() call in model unpickling that can cause deadlocks.
2016-02-08 08:28:48 -05:00
Joshua Phillips
16baec5c8a
Fixed #25910 -- Rejected read-only property names in model constructors.
2016-01-22 13:27:11 -05:00
Varun Sharma
692d055890
Fixed #25984 -- Corrected RuntimeError message in ModelBase.__new__().
2015-12-24 16:44:58 -05:00
Tim Graham
54e2e688e1
Fixed #25715 -- Fixed Model.refresh_from_db() with ForeignKey w/on_delete=SET_NULL.
2015-11-21 10:34:01 -05:00
Simon Charette
4cd5d846d4
Fixed #25730 -- Made Model.__str__() always return str instances.
...
Thanks to Kevin Turner for the report and Tim for the review.
2015-11-11 12:18:52 -05:00