#14120: [patch] Document ``get()`` in Making Queries
---------------------------+------------------------------------------------
 Reporter:  danielr        |       Owner:  nobody    
   Status:  new            |   Milestone:            
Component:  Documentation  |     Version:  1.2       
 Keywords:                 |       Stage:  Unreviewed
Has_patch:  1              |  
---------------------------+------------------------------------------------
 There's a frequent confusion among new users about the use of `filter()`
 when the query returns a single element - not realising that it will
 always return a !QuerySet, they try and access model properties on the
 returned value, and get annoyed when they don't work. See for example
 here: [http://stackoverflow.com/questions/3491075/comments-and-content-
 object], but similar queries come up all the time.

 This is really a documentation issue, in that the main introductory page
 on Making Queries does not explain that `filter()` will always return a
 !QuerySet, and neither does it explicitly document the `get()` alternative
 that is what the users in these cases probably should be using. `get()` is
 mentioned in passing on this page, and fully documented in the QuerySet
 API reference, but should be explained in full on this page, which is the
 first page users will go to.

 Attached patch adds a "Retrieving a single object with get" section after
 the `filter()` documentation.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/14120>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to