Skip to content

Commit

Permalink
Add deprecation warning for pre_save_duplicate (#693)
Browse files Browse the repository at this point in the history
* Add deprecation warning for pre_save_duplicate

* Update mixin.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Tonye Jack <jtonye@ymail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 10, 2022
1 parent 5a49bda commit 257caec
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion model_clone/mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import warnings
from itertools import repeat
from typing import Dict, List, Optional

Expand Down Expand Up @@ -197,7 +198,20 @@ def bulk_clone_multi(cls, objs, attrs=None, batch_size=None):
pass

def pre_save_duplicate(self, instance): # pylint: disable=R0201
"""Override this method to modify the duplicate instance before it's saved."""
"""
This method has been deprecated and would be removed in the 5.0.0 release.
Please use `pre_clone_save` signal instead.
See: https://github.com/tj-django/django-clone#signals for guidance.
"""
# TODO: Remove prior to v5.0.0 release
warnings.warn(
"The usage of `pre_save_duplicate` has been deprecated "
"and would be removed in the 5.0.0 release "
"Please use `pre_clone_save` signal instead.",
DeprecationWarning,
stacklevel=2,
)
return instance

@transaction.atomic
Expand Down

0 comments on commit 257caec

Please sign in to comment.