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

a question about BooleanField #9407

Closed
fanmaoyu0871 opened this issue May 17, 2024 · 3 comments
Closed

a question about BooleanField #9407

fanmaoyu0871 opened this issue May 17, 2024 · 3 comments

Comments

@fanmaoyu0871
Copy link

mysql table struct,the column is bit type:
微信图片_20240517102212

mysql data:
image

django model :
image

drf serializer:
image

http response:
image

my database value is 0,but it always return ”true“,i don't know why.

@angusholder
Copy link

MySQL doesn't have a dedicated bool type, so Django has to store bools as an integer. But models.BooleanField automatically converts the integer back to a bool after loading from the database; this is expected behaviour

@fanmaoyu0871
Copy link
Author

MySQL doesn't have a dedicated bool type, so Django has to store bools as an integer. But models.BooleanField automatically converts the integer back to a bool after loading from the database; this is expected behaviour

you see my value is 0, it's alway return true

@auvipy
Copy link
Member

auvipy commented May 27, 2024

Any questions should be ask here instead https://github.com/encode/django-rest-framework/discussions

@tomchristie tomchristie closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
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

4 participants