Django

Code

Changeset 5808

Show
Ignore:
Timestamp:
08/05/07 23:52:14 (1 year ago)
Author:
adrian
Message:

Edited docs/newforms.txt changes from [5804]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/newforms.txt

    r5804 r5808  
    15121512To work around this problem, every time you save a form using ``commit=False``, 
    15131513Django adds a ``save_m2m()`` method to the form created by ``form_for_model``. 
    1514 After you have manually saved the instance produced by the form, you can invoke 
    1515 ``save_m2m()`` to save the many-to-many form data:: 
     1514After you've manually saved the instance produced by the form, you can invoke 
     1515``save_m2m()`` to save the many-to-many form data. For example:: 
    15161516 
    15171517    # Create a form instance with POST data. 
    15181518    >>> f = AuthorForm(request.POST) 
    15191519 
    1520     # Create, but don't save the new author instance 
     1520    # Create, but don't save the new author instance. 
    15211521    >>> new_author = f.save(commit=False) 
    15221522 
    1523     # Modify the author in some way 
    1524     ... 
    1525     # Save the new instance 
     1523    # Modify the author in some way. 
     1524    >>> new_author.some_field = 'some_value' 
     1525 
     1526    # Save the new instance. 
    15261527    >>> new_author.save() 
    15271528 
    1528     # Now save the many-to-many data for the form 
     1529    # Now, save the many-to-many data for the form. 
    15291530    >>> f.save_m2m() 
    15301531 
    15311532Calling ``save_m2m()`` is only required if you use ``save(commit=False)``. 
    1532 When you use a simple ``save()`` on a form, all data - include 
    1533 many-to-many data - is saved without the need for any additional method calls. 
     1533When you use a simple ``save()`` on a form, all data -- including 
     1534many-to-many data -- is saved without the need for any additional method calls. 
     1535For example:: 
     1536 
     1537        # Create a form instance with POST data. 
     1538        >>> f = AuthorForm(request.POST) 
     1539 
     1540    # Create and save the new author instance. There's no need to do anything else. 
     1541    >>> new_author = f.save() 
    15341542 
    15351543Using an alternate base class