Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
andrewcirel opened this issue Dec 27, 2021 · 0 comments

Comments

@andrewcirel
Copy link

andrewcirel commented Dec 27, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant