我想按 user.username 过滤通知,我该怎么做?
模型.py
class Notification(BaseModelo):
user = models.ForeignKey(User, on_delete=models.CASCADE)
text = models.CharField(max_length=200)
state = models.BooleanField(default=False)
架构.py
class NotificationNode(DjangoObjectType):
class Meta:
model = Notification
filter_fields = ['user']
interfaces = (Node, )
class Query(ObjectType):
user = Node.Field(UserNode))
all_users = DjangoConnectionField(UserNode)
notification = Node.Field(NotificationNode)
all_notifications = DjangoFilterConnectionField(NotificationNode)