mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Made a bunch of doc improvements
git-svn-id: http://code.djangoproject.com/svn/django/trunk@41 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
Database API reference
|
||||
======================
|
||||
|
||||
XXX INTRO HERE XXX
|
||||
Once you've created your `data models`_, you'll need to lookup data from the
|
||||
database. This document explains the database abstraction API derived from the
|
||||
models, and how to create, retrieve, and update objects.
|
||||
|
||||
.. _`data models`: http://www.djangoproject.com/documentation/model_api/
|
||||
|
||||
Throughout this reference, we'll refer to the following Poll application::
|
||||
|
||||
@@ -287,6 +291,18 @@ For example::
|
||||
|
||||
SELECT * FROM polls_polls WHERE question LIKE 'Who%' AND id IN (3, 4, 5, 20);
|
||||
|
||||
Changing objects
|
||||
================
|
||||
|
||||
Once you've retrieved an object from the database using any of the above
|
||||
options, changing it is extremely easy. Make changes directly to the
|
||||
objects fields, then call the object's ``save()`` method::
|
||||
|
||||
>>> p = polls.get_object(id__exact=15)
|
||||
>>> p.slug = "new_slug"
|
||||
>>> p.pub_date = datetime.datetime.now()
|
||||
>>> p.save()
|
||||
|
||||
Creating new objects
|
||||
====================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user