Fix SoftDeletableModel.delete() forwarding positional args to superclass

The `soft` argument was made keyword-only, to avoid conflicts with new
positional arguments that might be added to Django. It was already
conflicting with the `keep_parents` argument.

The `using` argument is now passed to the superclass positionally,
as otherwise it can overlap with `*args`, resulting in a `TypeError`
on calls where `keep_parents` is passed positionally.
This commit is contained in:
Maarten ter Huurne 2023-03-20 13:33:47 +01:00
parent a86c14e4e7
commit 2d7139363c
2 changed files with 3 additions and 2 deletions

View file

@ -12,6 +12,7 @@ To be released
- Make `contribute_to_class()` in `StatusField`, `MonitorField` and `SplitField`
forward additional arguments to Django
- `SplitField` no longer accepts `no_excerpt_field` as a keyword argument
- Make `soft` argument to `SoftDeletableModel.delete()` keyword-only
4.4.0 (2024-02-10)
------------------

View file

@ -146,7 +146,7 @@ class SoftDeletableModel(models.Model):
available_objects = SoftDeletableManager()
all_objects = models.Manager()
def delete(self, using=None, soft=True, *args, **kwargs):
def delete(self, using=None, *args, soft=True, **kwargs):
"""
Soft delete object (set its ``is_removed`` field to True).
Actually delete object if setting ``soft`` to False.
@ -155,7 +155,7 @@ class SoftDeletableModel(models.Model):
self.is_removed = True
self.save(using=using)
else:
return super().delete(using=using, *args, **kwargs)
return super().delete(using, *args, **kwargs)
class UUIDModel(models.Model):