Commit graph

200 commits

Author SHA1 Message Date
Matthieu Rigal
5ca515acc7 docs: Fix Markdown formatting of CHANGES 2021-10-11 09:59:26 +02:00
Matthieu Rigal
e4629a013d
Prepare 4.2.0 release 2021-10-09 23:18:08 +02:00
Matthieu Rigal
a1920d2132
Merge pull request #499 from joshuadavidthomas/python3.10
Add support for Python 3.10
2021-10-09 22:45:12 +02:00
Matthieu Rigal
6d4112e8ce
Fix performance regression: avoid pickling the whole instance when deepcopying fields on Django 3.1+ (#500)
* test: Add failing test for #gh-498

* fix: Fix performance regression on FileTracker for FileField on Django 3.1+
2021-10-09 21:30:12 +06:00
Josh
6736a5b4e3 Update CHANGES.rst 2021-10-08 09:16:44 -05:00
Sergey Tikhonov
79a7793dc5
#491 Context manager for resetting fields (#494)
* Add tracker context manager and decorator

* Handle auto-field warning in tests

* Use tracker context in monkey-patched methods

* Test delaying set_saved_fields call with context manager

* Docs for tracker context

* Describe FieldsContext context manager in changes

* Fix unused import

* #494 add breaking changes note on 4.1.1 release for #404

* #494 fix typo

* #494 add docstring for FieldsContext

* #494 move breaking changes from 4.1.1 to 4.1.0

* #494 fix typo and add some more docstrings
2021-10-08 15:09:20 +06:00
Nafees Anwar
a56d07cd68 Added urlsafe token field 2021-04-30 21:40:39 +05:00
Jannis Leidel
4b90629e34
Tiny update for less screaming. 2021-04-08 14:54:11 +02:00
Hasan Ramezani
8e19699b0f Drop support for Django 3.0. 2021-04-07 10:32:50 +02:00
Hasan Ramezani
7af903b12a Add support for Django 3.2. 2021-04-07 10:32:50 +02:00
Simon Charette
f482042025 Add a release date for 4.1.1. 2020-12-01 18:12:57 -05:00
Hasan Ramezani
2269f810c8 Fix TypeError in save when model inherits from both TimeStampModel and StatusModel. (Fixes GH-465) 2020-12-02 00:07:22 +01:00
David Smith
79ff8ea6be
Used isort to sort imports (#460) 2020-11-29 20:58:00 +00:00
Simon Charette
b0be6e2422 Adjust CHANGES to mention 4.1.0 release and add missing changes. 2020-11-29 09:42:26 -05:00
Jannis Leidel
1b9e1fa435
Update changelog. 2020-11-29 14:53:42 +01:00
Hasan Ramezani
fed287e6fb Update test requirements. 2020-09-17 20:44:42 +06:00
H. Buğra Aydın
2ad67e77b1
Add status_changed field to upload_fields parameter during save if status field is present (#441)
* implementation/tests

* naming problem
2020-09-17 20:34:57 +06:00
Hasan Ramezani
b7770165d5 Add support for Django 3.1 2020-09-17 17:27:55 +06:00
Craig Anderson
b7a160936f Add available_objects soft deletable model manager. Emit deprecation warning when using objects soft deletable manager. 2020-08-25 16:40:09 +06:00
Skia
33e46ebd53 managers: avoid querying too much tables when not needed
When calling `select_related()` with an empty list of arguments [1], Django will
try to prefetch some data by doing some first level joints with the related
classes.
This can lead to obvious negative performance impact, but this also breaks some
workarounds for having inheritance for foreign keys [2], as those solutions rely
on lazy evaluation of the related object.

[1]: a4e6030904/django/db/models/query.py (L1051)
     Only passing an explicit `None` to `select_related` will disable the magic.
[2]: https://github.com/jazzband/django-model-utils/issues/11

As examples, here are the generated SQL requests in
InheritanceManagerRelatedTests.test_get_method_with_select_subclasses_check_for_useless_join:

  * without this fix, without adding `.select_related(None)`
```sql
SELECT
    "tests_inheritancemanagertestparent"."id",
    "tests_inheritancemanagertestparent"."non_related_field_using_descriptor",
    "tests_inheritancemanagertestparent"."related_id",
    "tests_inheritancemanagertestparent"."normal_field",
    "tests_inheritancemanagertestparent"."related_self_id",
    "tests_inheritancemanagertestchild4"."other_onetoone_id",
    "tests_inheritancemanagertestchild4"."parent_ptr_id", T3."id",
    T3."non_related_field_using_descriptor", T3."related_id", T3."normal_field",
    T3."related_self_id"
FROM
    "tests_inheritancemanagertestchild4"
INNER JOIN
    "tests_inheritancemanagertestparent" ON
    ("tests_inheritancemanagertestchild4"."parent_ptr_id" = "tests_inheritancemanagertestparent"."id")
INNER JOIN
    "tests_inheritancemanagertestparent" T3 ON
    ("tests_inheritancemanagertestchild4"."other_onetoone_id" = T3."id")
WHERE
    "tests_inheritancemanagertestchild4"."parent_ptr_id" = 191
```

  * with either the fix, or by adding `.select_related(None)` after `.select_subclasses()`
```sql
SELECT
    "tests_inheritancemanagertestparent"."id",
    "tests_inheritancemanagertestparent"."non_related_field_using_descriptor",
    "tests_inheritancemanagertestparent"."related_id",
    "tests_inheritancemanagertestparent"."normal_field",
    "tests_inheritancemanagertestparent"."related_self_id",
    "tests_inheritancemanagertestchild4"."other_onetoone_id",
    "tests_inheritancemanagertestchild4"."parent_ptr_id"
FROM
    "tests_inheritancemanagertestchild4"
INNER JOIN
    "tests_inheritancemanagertestparent" ON
    ("tests_inheritancemanagertestchild4"."parent_ptr_id" = "tests_inheritancemanagertestparent"."id")
WHERE
    "tests_inheritancemanagertestchild4"."parent_ptr_id" = 191

```
2020-07-08 16:59:05 +06:00
H. Buğra Aydın
b0a6b78c80 added explanation for the new feature
i forgot to change changes file to explain the feature below, updating accordingly:

3e32ae257b
2020-03-02 16:46:09 +06:00
Martín Raúl Villalba
6fba04ec4f Satisfy deprecation warning under Django 3.0.3 2020-03-01 08:55:31 +06:00
Sergey Tikhonov
1386c379b7 FieldTracker should patch save_base instead of save (#404)
* add test for reproducing FieldTracker update_fields issue

FieldTracker does not see update_fields changed in tracked model.save() method

* Patch Model.save_base instead of save

This change allows proper capturing update_fields kwarg if is is changed in overridden save() method.

* Add some details about FieldTracker implementation

* Mention FieldTracker behavior change
2019-12-15 22:43:58 +06:00
Sergey Tikhonov
d756a4a8ce patch Model.refresh_from_db in FieldTracker (#403)
* patch Model.refresh_from_db in FieldTracker

* add info about refresh_from_db patching to CHANGES.rst
2019-12-15 20:28:15 +06:00
Simon Charette
dd0d1bb01a
There's no 3.3.0 release. 2019-12-11 10:06:03 -05:00
Rémy HUBSCHER
35ba2bde31
Back to development 4.0.1 2019-12-11 15:48:26 +01:00
Rémy HUBSCHER
8af8cf269c
Prepare 4.0.0 release. 2019-12-11 15:47:18 +01:00
Misha K
5aa40c66be Add django 3.0 to the test matrix and drop six (#395)
*  - add django 3.0 to the test matrix
 - drop six

* add entry in CHANGES

* remove context kwarg

* fix test with DeferredAttribute

* rename StringyDescriptor's name to attname

* Fix flake8

* Drop support for Django 1.11 because the API are not compatibles anymore with Django 3.0

* Try to fix tests.

* Define model for the field mock.

* Simplifies the code.

* Properly mock the field.

* Typo

* Use the new API field name.

* Call it attname

* Grab the field instance from the model.

* Use postgres in travis tests.

* Django 2.0.1 minimum is needed.

* Update Changelog to tell about breaking Django 1.11.

* Update changelog to tell about Django 3.0 support.

* @natim review.
2019-12-09 19:37:16 +06:00
Hasan Ramezani
aa94194dbc Drop Python 2 support. (#394) 2019-09-30 14:08:52 +06:00
Rémy HUBSCHER
c19ea5b04f
Add changelog. 2019-08-21 11:19:13 +02:00
asday
488be3ff01 Updated documentation and bumped minor version. 2019-08-19 23:02:43 +01:00
Simon Charette
08e84eff69
Release 3.2.0. 2019-06-21 11:18:00 -04:00
Emin Bugra Saral
f5d4e5ce2b Update changes and authors 2019-05-20 19:45:51 +02:00
Asif Saif Uddin
25dde41418
Merge pull request #360 from marfyl/master
Add UUIDModel and UUIDField
2019-05-16 05:45:53 +06:00
Nick Sandford
d557c42533 Catch deferred attribute exception (#367) 2019-03-29 12:46:40 +06:00
Remy Suen
c4a252d1fb Explain usage of timeframed model manager in the documentation (#365)
* Provide a sample for using the timeframed manager

Signed-off-by: Remy Suen <remy.suen@gmail.com>

* Update CHANGES.rst file

Signed-off-by: Remy Suen <remy.suen@gmail.com>

* Update AUTHORS.rst file

Signed-off-by: Remy Suen <remy.suen@gmail.com>
2019-03-20 15:07:00 +06:00
Skia
1b9b5ac2c1 managers: honor OneToOneField.parent_link=False (#363) 2019-03-12 23:29:02 +06:00
JMP
5c49f2c7d0 Update changes.rst for UUIDModel and UUIDField 2019-02-26 18:41:23 +01:00
Diego Navarro
4e18710537 Upgrades pytest, pytest-django and pytest-cov version to fix travis build (#358)
* Upgrades pytest, pytest-django and pytest-cov version

* Skips testing Python 3.5 with django trunk (Django 2.1 requires Python 3.6)
2019-02-22 00:05:35 +06:00
Zach Cheung
af1824e200 fix conflict 2019-01-11 17:26:06 +08:00
Sergey Tikhonov
6b88c888d3 fix model.save patched in FieldTracker (#353)
* fix model.save patched in FieldTracker

* add test for save call with args

* update changes
2018-12-10 21:35:26 +06:00
Daniel Andrlik
25743141bc Ensure TimeStampedModel modified equals created on initial creation. (#319)
*  Ensure TimeStampedModel modified equals created on initial creation.

Add logic to AutoLastModifiedField which checks to see if the associated created field of the correct cField class type is also present. If the instance has not yet been saved (missing a pk), then set the value to modified to be equal to created.

Fixes #247

📚 Update changes and authors list related to changes.

* 🚑 Set TimeStampedModel modified to be equal to created during first save.

If instance does not yet have a pk, before defaulting the last modified to the current time, iterate over the the fields of the model, and instead use whatever value is found in the first occurance of the AutoCreatedField.

Fixes #247

* Move changelog up to unreleased section.
2018-12-08 12:23:04 +06:00
Guilherme Devincenzi
b739f6fe87 Add default manager as all_objects for SoftDeletableModel (#326)
* Add default manager as all_objects for SoftDeletableModel

* Document changes on changelog
2018-12-08 11:50:10 +06:00
Éric Araujo
764b7ea78d Add support for reverse iteration of Choices (#314) 2018-12-08 11:47:54 +06:00
tumb1er
ba83be0b43 fix #330 patch MyModel.save instead of MyModel().save 2018-11-20 18:32:09 +03:00
Zach Cheung
300209007b add Simplified Chinese translations 2018-10-23 15:38:04 +08:00
Lucas Wiman
45502c0ec2
Put changelog in the right place. 2018-06-30 15:52:00 -07:00
Lucas Wiman
98a1366608 Merge branch 'defer-has-changed' into django-1.11-compatibility 2018-06-21 12:52:33 -07:00
Lucas Wiman
be1a7d9281 Update AUTHORS and CHANGES.
As far as I can tell, no changes to documentation is required.
2018-06-21 12:41:42 -07:00
João Amaro
6d2ba63387 update changelog and versions for 3.1.2 2018-05-09 14:45:37 -03:00