Reputation: 36217
I'm using the django console to try to test a query on my sqllite DB.
The table's model starts with:
class Message(models.Model):
mailbox = models.ForeignKey(Mailbox, related_name='messages')
subject = models.CharField(max_length=255)
message_id = models.CharField(max_length=255)
in_reply_to = models.ForeignKey(
'django_mailbox.Message',
related_name='replies',
blank=True,
null=True,
)
........
Here is my attempt at testing in the django console:
>>> from django_mailbox.models import Message
>>> o = Message.objects.all()
>>> o
[<Message: Get Gmail for your mobile device>, <Message: Tips for using Gmail>, <Message: Welcome to Gmail>, <Message: Getting started on Google+>, '...(remaining elements truncated)...']
>>> o = Message.objects.filter(in_reply_to > 0)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'in_reply_to' is not defined
As you can see Message.objects.all() works. But when I try to filter by a particular field having a positive value I get the error. What am I doing wrong?
Upvotes: 0
Views: 114