Skip to content

How to retrieve a BitField flag value in a queryset filter using values. #125

@andrewcirel

Description

@andrewcirel

If I do the below filter, using ".values" to retrieve profile related values from multiple tables, the bitfield 'interests' is converted into a normal number.
profiles = Profile.objects.filter(to_profile__from_profile=request.user.id).values('id', 'nickname', 'age', 'location', 'country__name', 'description', 'to_profile__like', 'to_profile__favourite', 'interests', 'photo1', 'photo2', 'photo3')
Once the BitField 'interests' is converted into a normal number, if you try and use it you get the error: 'int' object has no attribute 'flags'. It would be very useful if you could pass a number into the BitField and use the flags option. Without this option BitField cannot be used with .values or .value_lists which are very useful filter options.
I admit this is similar to the issue "#98", but that didn't include ".values" and also didn't suggest a solution of passing the number into BitField.

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