Commit graph

432 commits

Author SHA1 Message Date
Maarten ter Huurne
00e52e8508 Explicitly re-export names from __init__ module
Both mypy and flake8 understand `__all__`, removing the need for
warning suppression comments.
2024-03-22 14:50:31 +01:00
Guilherme Martins Crocetti
22015b8e69
chore(monitor-field): Add deprecation warning when the field is null and no default is provided. The new behavior will be introduced in a next major release 2024-03-21 20:05:14 -03:00
Jelmer
89b7662fa8
Merge pull request #567 from ProtixIT/remove-clone-args
Remove arguments from `InheritanceQuerySetMixin._clone()`
2024-03-21 15:33:02 +01:00
Jelmer
7b8a58b871
Merge pull request #580 from joecox/remove-dead-tracker-code
Remove dead `init_deferred_fields` method
2024-03-21 08:47:53 +01:00
Jelmer
f39c975e8b
Merge branch 'master' into ptbr-translations 2024-03-21 08:36:00 +01:00
meanmail
5663374890 Don't use post_init signal for initialize tracker 2024-03-11 17:50:12 +01:00
Joseph Riddle
55cd816939
Merge branch 'master' into fix-prefetch-related 2023-11-27 12:55:53 -08:00
Adam Johnson
11f3a53b0f Remove SaveSignalHandlingModel 2023-10-26 16:56:30 +01:00
Joe Cox
b2a10bd96c remove dead init_deferred_fields method 2023-09-11 16:25:16 -07:00
Guilherme Martins Crocetti
055932bb8b
feat(locale): Add translations for pt_BR 2023-08-01 11:26:41 -03:00
Serhii Tereshchenko
0ec4ac5e38
fix: Use proper column name instead of attname (#573)
fix: Use proper column name instead of attname
2023-06-16 15:34:47 +02:00
Jelmer
6916342126
Merge pull request #552 from patrick91/master
Add py.typed file
2023-06-16 11:46:15 +02:00
Jelmer
23e7ee3382
Merge branch 'master' into swedish-translation 2023-06-16 11:25:36 +02:00
Hugo van Kemenade
b76c6c497b Replace setuptools' pkg_resources with stdlib importlib.metadata 2023-06-15 17:49:51 +03:00
Maarten ter Huurne
033fca4e2d Remove arguments from InheritanceQuerySetMixin._clone()
The `QuerySet._clone()` method has no arguments in either Django 3.2
or 4.1, so I'm assuming the arguments were necessary for a version
of Django that is no longer supported by `django-model-utils`.
2023-04-19 22:14:27 +02:00
Tomas Walch
41fd090e25 Swedish translation 2023-04-06 14:35:28 +02:00
joeriddles
a0624f1492 For error on prefetch_related for tracked field 2023-01-26 13:17:49 -08:00
Patrick Arminio
bfa95b1baf Add py.typed 2023-01-23 22:03:56 +00:00
Hasan Ramezani
0b5475e3d5 Add pyupgrade to pre-commit configurations 2022-08-17 23:08:31 +02:00
Adam Johnson
d699745504 Remove workaround from select_subclasess()
The workaround was for an issue that was fixed in Django 1.7: https://code.djangoproject.com/ticket/16855 / 349c12d3f5 .
2022-08-17 23:06:50 +02:00
Tim Gates
2dab8afded docs: Fix a few typos
There are small typos in:
- docs/managers.rst
- model_utils/managers.py
- tests/test_models/test_timestamped_model.py

Fixes:
- Should read `subclasses` rather than `subclasess`.
- Should read `queryset` rather than `querset`.
- Should read `permissible` rather than `permissable`.
- Should read `modified` rather than `modifed`.
- Should read `heterogeneous` rather than `heterogenous`.

Signed-off-by: Tim Gates <tim.gates@iress.com>
2022-08-17 22:37:49 +02:00
John Vandenberg
70b949cd2c
Merge branch 'master' into spanish_translation 2022-03-14 10:36:04 +08:00
John Vandenberg
53b23c84c5
Merge pull request #473 from Sicilia04/master
Adds French translation
2022-03-14 10:34:06 +08: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
tumb1er
dd0f62bdba Fix QuerySet._chain for django main (post-3.2) 2021-10-09 16:52:50 +06:00
Josh
8f4f24f88c fix Callable import
The ability to import from `collections` was removed in 3.10.
2021-10-08 09:05:33 -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
9deb39dc46 Added deconstruct 2021-04-30 21:40:39 +05:00
Nafees Anwar
a56d07cd68 Added urlsafe token field 2021-04-30 21:40:39 +05:00
Florian Alu
3a1bcc7ccb Add French translation 2021-01-11 11:57:01 +01: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
Jannis Leidel
e630935fa3
Please coverage 2020-11-29 15:00:33 +01:00
Jannis Leidel
1336a91d75
Merge branch 'master' into gha 2020-11-29 14:42:23 +01:00
Jannis Leidel
2cd07a9e89
Use setuptools_scm 2020-11-29 14:39:17 +01:00
Hasan Ramezani
92ff6b927f Remove codes related to old versions of Django. 2020-11-28 21:46:25 +01:00
Ben Steinberg
eba26d6bd4 Fix typo 2020-10-29 09:11:30 -04:00
Arseniy Panfilov
e9c45c71d1 update implementation of TimeStampedModel.save to handle various ways of specifying 'update_fields' 2020-10-15 15:51:33 +06:00
Hasan Ramezani
be1c0f571e Add farsi translation. 2020-09-23 09:29:26 +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
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
skazancev
bf4b65a437 removed model from DeferredAttributeTracker 2020-05-28 22:40:13 +06:00
Enrique Matías Sánchez (Quique)
c6ce8fea25 Add Spanish translation 2020-03-29 11:31:31 +02:00
Martín Raúl Villalba
6fba04ec4f Satisfy deprecation warning under Django 3.0.3 2020-03-01 08:55:31 +06:00
H. Buğra Aydın
3e32ae257b Overriding TimeStampedModel's save() method (#412)
* Overriding TimeStampedModel's save() method

to update modified field automatically when update_fields argument is used but modified was not given as a parameter.

* fixed a small error in logic

* added tests for new functionality
2020-01-23 13:19:06 +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
Rémy HUBSCHER
35ba2bde31
Back to development 4.0.1 2019-12-11 15:48:26 +01:00