On Monday, 25 November 2013 21:42:51 UTC, Timothy W. Cook wrote:
-- On Mon, Nov 25, 2013 at 8:22 AM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Sunday, 24 November 2013 18:46:21 UTC, Timothy W. Cook wrote:
>>
>> On Sun, Nov 24, 2013 at 4:38 PM, Daniel Roseman <dan...@roseman.org.uk>
>> wrote:
>
> No, `f` is now an unsaved instance of the Review model, rather than a form
> (you should probably make that clearer by calling the instance `r` or
> `review`).
I will certainly call it something else now that I realize:
f = form.save(commit=False)
means to make a copy of the model without saving it to disk. I
previously (from the SO example) thought I was making a copy of he
form.
IT still isn't clear how form.save yeailds a copy of the model and not
a copy of the form.
> So you can modify it like you would any other model instance
> before calling save() - and of course this is the normal model save(), not
> the form's.
So the follow on to that is how (if 'f' is a model instance) does the
form data get into my model instance. I am sure that there is
somewhere in the docs or at least in the code that this can be seen?
But that's just what form.save() does. In your original code, you called it and a new Review object was saved in the database (it was also returned, but you didn't use it). The only difference here is that you've added the commit=False parameter, which does everything it did before except actually saving to the database.
--
DR.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6b57a656-73fb-4bc4-a94c-aaa0b99a7bef%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment