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

Remove JoinManager class #613

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
- Remove `JoinManager` and `JoinManagerMixin`; use ``JoinQueryset.as_manager()`` instead

4.4.0 (2024-02-10)
------------------
Expand Down
15 changes: 0 additions & 15 deletions model_utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,18 +382,3 @@ class Meta:
)
new_qs.query.join(conn, reuse=None)
return new_qs


class JoinManagerMixin:
"""
Manager that adds a method join. This method allows you to join two
querysets together.
"""
_queryset_class = JoinQueryset

def get_queryset(self):
return self._queryset_class(model=self.model, using=self._db)


class JoinManager(JoinManagerMixin, models.Manager):
pass
6 changes: 3 additions & 3 deletions tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from model_utils import Choices
from model_utils.fields import MonitorField, SplitField, StatusField, UUIDField
from model_utils.managers import InheritanceManager, JoinManager, QueryManager
from model_utils.managers import InheritanceManager, JoinQueryset, QueryManager
from model_utils.models import (
SoftDeletableModel,
StatusModel,
Expand Down Expand Up @@ -394,7 +394,7 @@ class ModelWithCustomDescriptor(models.Model):

class BoxJoinModel(models.Model):
name = models.CharField(max_length=32)
objects: ClassVar[JoinManager[BoxJoinModel]] = JoinManager()
objects = JoinQueryset.as_manager()


class JoinItemForeignKey(models.Model):
Expand All @@ -404,7 +404,7 @@ class JoinItemForeignKey(models.Model):
null=True,
on_delete=models.CASCADE
)
objects: ClassVar[JoinManager[JoinItemForeignKey]] = JoinManager()
objects = JoinQueryset.as_manager()


class CustomUUIDModel(UUIDModel):
Expand Down
Loading