Reputation: 4380
I was just checking if a change I had made to my models had taken affect when I started to get this for some (but not all) of my models. I've never seen this before and I'm fairly certain I've had no issue querying these models in the past.
>>> record = Record.objects.get(id=1)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/alittlesquid/grocerygod/fratgroceries/ggenv/local/lib/python2.7/site-packages/django/db/models/manager.py", line 143, in get
return self.get_query_set().get(*args, **kwargs)
File "/usr/local/alittlesquid/grocerygod/fratgroceries/ggenv/local/lib/python2.7/site- packages/django/db/models/query.py", line 404, in get
self.model._meta.object_name)
DoesNotExist: Record matching query does not exist.
After more digging I discovered that a query for all Record.objects.all()
works as expected. Can anyone shed light on why this would be happening to some of my models? A fix would also be tremendously helpful, thanks.
Upvotes: 3
Views: 4805
Reputation: 1088
There is probably no Record
with the id as 1 (maybe you meant pk?). You can easily verify this by running Record.objects.values("id")
and checking the output manually.
Upvotes: 1