Possible bug: Querying a model with an IntegerField value of 0 using mysql-connector/python returns a queryset where the field value becomes a NoneType 2.0.3.0
25 views
Skip to first unread message
Marcus Grass
unread,
Aug 19, 2018, 6:15:44 PM8/19/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi, I ran into a strange problem when i switched from using mysqlclient to mysql-connector/python.
In practice:
classFoo(models.Model): bar = models.IntegerField(default=0,null=False)
queryset =Foo.objects.all().filter(bar=0) print(queryset[0].bar)# prints None
Anyone know a fix for this?
Using python 3.6.6, Django 2.0.3.0-
Jason
unread,
Aug 19, 2018, 8:20:50 PM8/19/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
that is indeed weird, but suggests its an issue with python-mysql-connector, not django.
As you can see there, mysqlclient is the django project recommended way to interface with mysql. What are your reasons for going with mysql-connector-python?
Marcus Grass
unread,
Aug 20, 2018, 3:18:33 AM8/20/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Yeah I know it's recommended, but I can't for the life of my get that
connector to work in windows.
I program my project both in places where I only have windows and only Linux.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
rather than having your dev environment exist on two separate operating systems, you should use virtual machines with docker or vagrant for development. That way, your environment is identical through dev, staging and prod environments, except for env-specific settings. Consider this case, if you're working fine in Linux but Windows is blowing up, using docker or vagrant would make this a non-issue/