how to implement tinyInt(1) in python Django models file. I have tried like below but they give me the error. models.tinyInt1()
Asked
Active
Viewed 957 times
1
-
`models.BooleanField`? – Willem Van Onsem Sep 11 '21 at 06:48
1 Answers
0
Django model fields are supposed to be unaware of the SQL dialect of the database. This thus means that the database backend will transform this to the respective SQL column type.
A BooleanField
is conceptually equivalent to a tinyint(1)
, since a BooleanField
requires one bit: True
if it has 1
as value, and 0
for False
. In SQL dialects like MySQL, a tinyint
is equivalent to a boolean
.
Your model thus can implement this as:
class MyModel(models.Model):
condition = models.BooleanField()

Willem Van Onsem
- 443,496
- 30
- 428
- 555