Skip to content

Method get_<field>display() returns incorrectly in queries #1279

@ripperdoc

Description

@ripperdoc

I have a document called Product, and call the Mongoengine provided convenience method get_type_display() to return the correct display name of the current choice for the field "type".

This works when I display a single Product, but when displaying this for each Product in a QuerySet, it returns a default value for all fields. So the result is:

print product.type => 'digital'
print product.get_type_display() => 'item'  (incorrect value)
print product._BaseDocument__get_field_display(self._fields['type'])  => 'digital' (the correct value)

I was not able to find the root cause of the error, but want to start this issue thread to get some pointers. Right now, I'm using the last line in above example as a workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions