Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add available_objects soft deletable model manager #438

Merged
merged 1 commit into from
Aug 25, 2020
Merged

Add available_objects soft deletable model manager #438

merged 1 commit into from
Aug 25, 2020

Conversation

craiga
Copy link
Contributor

@craiga craiga commented Aug 12, 2020

Problem

As described in #364

Solution

  • Adds .available_objects manager to soft deletable models.
  • Keeps existing .objects manager, but emits a DeprecationWarning for each use of that manager.

Commandments

  • Write PEP8 compliant code.
  • Cover it with tests.
  • Update CHANGES.rst file to describe the changes, and quote according issue with GH-<issue_number>.
  • Pay attention to backward compatibility, or if it breaks it, explain why.
  • Update documentation (if relevant).

@craiga
Copy link
Contributor Author

craiga commented Aug 12, 2020

Still needs documentation. Just hoping for feedback on this approach for now.

@jonathan-s
Copy link
Contributor

This approach looks sane to me. Perhaps the link should be to the documentation instead for this? With regards to emitting too many warnings, I believe there is a way to silence warnings which could be mentioned in the documentation. If for nothing else this will bring people the notice of how things will work in the future and change things accordingly.


self.assertRaises(ConnectionDoesNotExist, instance.delete,
using='other', soft=False)

def test_can_only_see_not_removed_entries(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test named incorrectly.

…warning when using objects soft deletable manager.
@craiga craiga marked this pull request as ready for review August 21, 2020 12:01
@auvipy auvipy merged commit b7a1609 into jazzband:master Aug 25, 2020
@rjekker
Copy link

rjekker commented Mar 11, 2021

One thing is not clear for me:

does this mean that in the future, objects will again be the default Manager that returns everything?

What is currently the recommended way to get to deleted items when using SoftDeletableModel?

@craiga
Copy link
Contributor Author

craiga commented Mar 11, 2021

@rjekker Yep, that's right—objects will be a plain old simple manager.

I might be wrong, but there is no recommended way to get deleted items at the moment. That's part of the underlying issue this deprecation is trying to solve.

@craiga craiga deleted the soft-deletable-rename-managers branch April 5, 2021 13:38
tadamcz added a commit to tadamcz/django-model-utils that referenced this pull request Feb 12, 2024
tadamcz added a commit to tadamcz/django-model-utils that referenced this pull request Feb 12, 2024
@tadamcz
Copy link
Contributor

tadamcz commented Feb 12, 2024

Thanks for moving this along, @craiga! I added some clarification to the docs (#589) as I was initially confused.

cr313 added a commit to cr313/model-utils that referenced this pull request Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants