This is an error I recently got in Django and I couldn’t figure out why.
It is errors like this that don’t give an explanation for WHERE it’s being called that get me on a wild goose chase.
This is a MySQL error meaning you need to use AND. But since Django’s ORM takes care of the SQL for us, it’s hard for us casual users to know whats up.
Turns out one of my statements was passing a pair of values (value1, value2) to the object manager (filter).
So: If you have something like: some_model.objects.filter(field__lte=something), make sure that ’something’ is a single value, not a pair.
Now it makes sense why a two value pair would throw that MySQL error, if Django treats it like a single value.
Update: Comment from Ben might help others with this problem:
For others who may hit this, I suspect your problem is that get_or_create actually returns a tuple! (the value you think it should return, boolean telling you if the value was created)