facebook / facebook/pyrefly

Support for Django Manager/QuerySet

Open
#3,648 3 comments 11 reactions 1 assignee Claimed by @asukaminato0721 View on GitHub
django
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

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

Example:

```python
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.