Changeset 2862
- Timestamp:
- 05/06/06 17:55:30 (3 years ago)
- Files:
-
- django/trunk/docs/db-api.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/db-api.txt
r2855 r2862 336 336 337 337 To retrieve a *single* object rather than a list 338 (e.g. ``SELECT foo FROM bar LIMIT 1``), us inga simple index instead of a338 (e.g. ``SELECT foo FROM bar LIMIT 1``), use a simple index instead of a 339 339 slice. For example, this returns the first ``Entry`` in the database, after 340 340 ordering entries alphabetically by headline:: … … 342 342 Entry.objects.order_by('headline')[0] 343 343 344 This is equivalent to::344 This is roughly equivalent to:: 345 345 346 346 Entry.objects.order_by('headline')[0:1].get() 347 347 348 Note that either of these two examples will raise ``DoesNotExist`` if no349 objects match the given criteria.348 Note, however, that the first of these will raise ``IndexError`` while the 349 second will raise ``DoesNotExist`` if no objects match the given criteria. 350 350 351 351 QuerySet methods that return new QuerySets
