diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-01-16 18:56:44 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-01-16 18:56:44 +0000 |
| commit | d6bf53760b4e39248e1e2f622a569be7484545ea (patch) | |
| tree | cf4d890a6f234be65beec703ef52d9307822330a /docs/db-api.txt | |
| parent | 2221cdabff9f3d802b5321fb580b35d648d65c9e (diff) | |
magic-removal: Merged to [2010]
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2011 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/db-api.txt')
| -rw-r--r-- | docs/db-api.txt | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt index f4b4675c82..5261ab6fda 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -544,6 +544,25 @@ deletes the object and has no return value. Example:: >>> c.delete() +Comparing objects +================= + +To compare two model objects, just use the standard Python comparison operator, +the double equals sign: ``==``. Behind the scenes, that compares the primary +key values of two models. + +Using the ``Poll`` example above, the following two statements are equivalent:: + + some_poll == other_poll + some_poll.id == other_poll.id + +If a model's primary key isn't called ID, no problem. Comparisons will always +use the primary key, whatever it's called. For example, if a model's primary +key field is called ``name``, these two statements are equivalent:: + + some_obj == other_obj + some_obj.name == other_obj.name + Extra instance methods ====================== |
