mirror of
https://github.com/django/django.git
synced 2025-08-03 02:23:12 +00:00
Fixed #239 and #107 -- Changed model init() to use Field.get_default() if the value wasn't explicitly passed as a keyword argument. That means setting 'id=None' is no longer necessary, and you can leave off fields if you want them to have default values set.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@360 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
1a8fc57bf6
commit
b307fb09bb
5 changed files with 62 additions and 15 deletions
|
@ -333,8 +333,7 @@ Creating new objects
|
|||
Creating new objects (i.e. ``INSERT``) is done by creating new instances
|
||||
of objects then calling save() on them::
|
||||
|
||||
>>> p = polls.Poll(id=None,
|
||||
... slug="eggs",
|
||||
>>> p = polls.Poll(slug="eggs",
|
||||
... question="How do you like your eggs?",
|
||||
... pub_date=datetime.datetime.now(),
|
||||
... expire_date=some_future_date)
|
||||
|
@ -355,8 +354,7 @@ Related objects (i.e. ``Choices``) are created using convience functions::
|
|||
Each of those ``add_choice`` methods is equivilent to (except obviously much
|
||||
simpler than)::
|
||||
|
||||
>>> c = polls.Choice(id=None,
|
||||
... poll_id=p.id,
|
||||
>>> c = polls.Choice(poll_id=p.id,
|
||||
... choice="Over easy",
|
||||
... votes=0)
|
||||
>>> c.save()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue