Skip to content

use only for nested model fields #916

Closed

Description

@falled10

Hi There!

How to make only for nested model fields
Example:

class A:
    id = fields.IntField()
    name = fields.CharField()
    other_field = fields.CharField()

class B:
    id = fields.IntField()
    b_name = fields.CharField()
    a = fields.ForeignKeyField('models.A', related_name='Bs', on_delete=fields.CASCADE)
    
    
B.all().select_related('a').only('id', 'b_name', 'a__name')

This example will throw

KeyError: 'a__name'

Activity

  1. long2ice commented on Sep 22, 2021

    @long2ice
    Member

    Current you can use .values

  2. falled10 commented on Sep 23, 2021

    @falled10
    Author

    @long2ice this won't help if you want to use pydantic schemas :(

  3. oyish commented on Nov 14, 2021

    @oyish

    i need it too.

  4. Qlas commented on Sep 12, 2024

    @Qlas

    This feature could be useful in our project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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