Commit 00699f48 by Alex Gaynor

Document using commit=False on forms.

parent 274d1304
...@@ -33,3 +33,19 @@ apple "ball cat" dog ``["apple", "ball cat", "dog"]`` No commas, so space del ...@@ -33,3 +33,19 @@ apple "ball cat" dog ``["apple", "ball cat", "dog"]`` No commas, so space del
"apple" "ball dog ``["apple", "ball", "dog"]`` Unclosed double quote is ignored "apple" "ball dog ``["apple", "ball", "dog"]`` Unclosed double quote is ignored
====================== ================================= ================================================ ====================== ================================= ================================================
``commit=False``
~~~~~~~~~~~~~~~~
If, when saving a form you use the ``commit=False`` option you'll need to call
``save_m2m()`` on the form after you save the object, just as you would for a
form with normal many to many fields on it::
if request.method == "POST":
form = MyFormClass(requets.POST)
if form.is_valid():
obj = form.save(commit=False)
obj.user = request.user
obj.save()
# Without this next line the tags won't be saved.
form.save_m2m()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment