You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
When Django creates the SQL to get an object from model.objects.get() it doesn't look like SQL is adding a "LIMIT 1" to the end. As the get method is always intended to return a single item, would adding that to Django's SQL speed things up?
Karen Tracey
unread,
Feb 25, 2016, 10:20:37 AM2/25/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
This would hide errors in cases where there are more than one. Currently you will get an exception raised if you try a get() and more than a single result is returned, if a LIMIT 1 were added to the sql then this error situation would be hidden from developers.
Michal Petrucha
unread,
Feb 25, 2016, 10:31:57 AM2/25/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
In addition to what Karen said, you might want to consider using
qs.first() instead, which does what you describe, AFAIK – assuming, of
course, that you don't need the extra check for multiple returned
objects that you get with qs.get():
https://docs.djangoproject.com/en/1.9/ref/models/querysets/#first