Skip to content

如何同时使用only和select_related #1918

Closed

Description

@CyanZoy

怎么在only中指定select_related中表的字段
是否目前还未实现该功能
class A(Model):
id = fields.IntField(primary_key=True, description="ID")
name = fields.CharField(description="name", max_length=50)

class B(Model):
id = fields.IntField(primary_key=True, description="ID")
a = fields.ForeignKeyField("models.A", description="外键A", on_delete=fields.CASCADE)

eg:
await B.filter().select_related("a").only("id", "a__name") # just secelt B.id and A.name

Activity

  1. CyanZoy commented on Mar 5, 2025

    @CyanZoy
    Author

    the same question
    Status: Open.
    #916

  2. self-assigned this
    on Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions