Django

Code

Changeset 2862

Show
Ignore:
Timestamp:
05/06/06 17:55:30 (3 years ago)
Author:
lukeplant
Message:

Updated docs regarding QuerySet? slicing and IndexError?, in line with r2859

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/db-api.txt

    r2855 r2862  
    336336 
    337337To retrieve a *single* object rather than a list 
    338 (e.g. ``SELECT foo FROM bar LIMIT 1``), using a simple index instead of a 
     338(e.g. ``SELECT foo FROM bar LIMIT 1``), use a simple index instead of a 
    339339slice. For example, this returns the first ``Entry`` in the database, after 
    340340ordering entries alphabetically by headline:: 
     
    342342    Entry.objects.order_by('headline')[0] 
    343343 
    344 This is equivalent to:: 
     344This is roughly equivalent to:: 
    345345 
    346346    Entry.objects.order_by('headline')[0:1].get() 
    347347 
    348 Note that either of these two examples will raise ``DoesNotExist`` if no 
    349 objects match the given criteria. 
     348Note, however, that the first of these will raise ``IndexError`` while the  
     349second will raise ``DoesNotExist`` if no objects match the given criteria. 
    350350 
    351351QuerySet methods that return new QuerySets