Strange database problem in django

I have a weird database problem in django using sqlite:

In the model "PrivateMessage":

[..]
deleted_from = models.BooleanField(default=False)
[..]

B. / manage.py shell

In [8]: PrivateMessage.objects.filter(deleted_from=False)
Out[8]: []

In [9]: PrivateMessage.objects.filter(deleted_from=True)
Out[9]: []

In [10]: PrivateMessage.objects.get(id=9).deleted_from
Out[10]: False

I could only imagine that the database is corrupt. Any other ideas?

+3
source share
2 answers

This is a bug with south and sqlite: http://south.aeracode.org/ticket/600

+3
source

Maybe this is some kind of specific sqlite problem, but I really don't know. Just an idea of ​​what I will do.

You can look at the actual SQL query and check if this is correct:

# print PrivateMessage.objects.filter(deleted_from=False).query

Check what values ​​and types of model field deleted_from:

# [(m.deleted_from, type(m.deleted_from)) for m in PrivateMessage.objects.all()]
0
source

Source: https://habr.com/ru/post/1783611/


All Articles