diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2006-06-27 20:36:25 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2006-06-27 20:36:25 +0000 |
| commit | 48562965b900bd8d4ba5f6fef4b635af844b5cee (patch) | |
| tree | 01f9d4bdf1790bb6882ff25b695cf907233726c6 /docs | |
| parent | 2adbe11678030a019c1e279501e688acae3f85ce (diff) | |
Added {{{Manager.create()}}} method to create and save an object in a single step.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3217 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/db-api.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/db-api.txt b/docs/db-api.txt index 5108949184..15b70ee028 100644 --- a/docs/db-api.txt +++ b/docs/db-api.txt @@ -60,6 +60,10 @@ the database until you explicitly call ``save()``. The ``save()`` method has no return value. +To create an object and save it all in one step see the `create`__ method. + +__ `create(**kwargs)`_ + Auto-incrementing primary keys ------------------------------ @@ -705,6 +709,20 @@ The ``DoesNotExist`` exception inherits from except ObjectDoesNotExist: print "Either the entry or blog doesn't exist." +``create(**kwargs)`` +~~~~~~~~~~~~~~~~~~~~ + +A convenience method for creating an object and saving it all in one step. Thus:: + + p = Person.objects.create(first_name="Bruce", last_name="Springsteen") + +and:: + + p = Person(first_name="Bruce", last_name="Springsteen") + p.save() + +are equivalent. + ``get_or_create(**kwargs)`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
