schneck
schneck

Reputation: 10827

Weird database issue in django

I have a strange database problem in django, using sqlite:

In the Model "PrivateMessage":

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

In ./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?

Upvotes: 3

Views: 203

Answers (2)

schneck
schneck

Reputation: 10827

It's a bug with south and sqlite: http://south.aeracode.org/ticket/600

Upvotes: 3

Haes
Haes

Reputation: 13116

Maybe it is some sqlite specific problem, but actually I don't know. Just some idea's what I would do.

You could take a look at the actual SQL query and check if it is correct:

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

Check what's the values and types of the deleted_from model field:

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

Upvotes: 0

Related Questions