Skip to content

Support for Django Manager/QuerySet #3648

@maxhollmann

Description

@maxhollmann

Are you planning to support Django's Manager/QuerySet interaction?

Example:

from django.db import models


class NotificationQuerySet(models.QuerySet["Notification"]):
    def resolved(self):
        return self.filter(resolved_at__isnull=False)


class Notification(models.Model):
    resolved_at = models.DateTimeField(null=True, blank=True)

    objects = NotificationQuerySet.as_manager()


Notification.objects.resolved()
# => Object of class `Manager` has no attribute `resolved`

Notification.objects.all().resolved()
# .all() resolves to QuerySet[Notification, Notification]
# => Object of class `QuerySet` has no attribute `resolved`

I would expect both of these to work. Similarly for related managers, e.g. user.notification_set.resolved().

Apologies if there's already an issue about this, I've looked and couldn't find one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions