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
to Django users
Hi, I ran into a strange problem when i switched from using mysqlclient to mysql-connector/python.

In practice: 
class Foo(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
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
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 received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6be9073b-34f1-445f-ba02-dabf09c9916c%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Jason

unread,
Aug 20, 2018, 6:32:42 AM8/20/18
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/
Reply all
Reply to author
Forward
0 new messages