Re: Form cleaned_data

2013-11-27 Thread Timothy W. Cook
Thanks Tom. On Wed, Nov 27, 2013 at 8:13 AM, Tom Evans wrote: > > No, "form" is an instance of your form. Model forms have a method > called save(), when you call this method, the model form updates an > instance of the model with the values from the form, saves the > instance and then returns it

Re: Form cleaned_data

2013-11-27 Thread Tom Evans
On Wed, Nov 27, 2013 at 9:50 AM, Timothy W. Cook wrote: > On Tue, Nov 26, 2013 at 9:34 AM, Daniel Roseman wrote: >> On Monday, 25 November 2013 21:42:51 UTC, Timothy W. Cook wrote: >> >> But that's just what form.save() does. In your original code, you called it >> and a new Review object was sav

Re: Form cleaned_data

2013-11-27 Thread Timothy W. Cook
On Tue, Nov 26, 2013 at 9:34 AM, Daniel Roseman wrote: > On Monday, 25 November 2013 21:42:51 UTC, Timothy W. Cook wrote: > > 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

Re: Form cleaned_data

2013-11-26 Thread Daniel Roseman
On Monday, 25 November 2013 21:42:51 UTC, Timothy W. Cook wrote: > > On Mon, Nov 25, 2013 at 8:22 AM, Daniel Roseman > > > 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 > > >> wrote: > > > > > No, `f` i

Re: Form cleaned_data

2013-11-25 Thread Timothy W. Cook
On Mon, Nov 25, 2013 at 8:22 AM, Daniel Roseman 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 >> wrote: > > No, `f` is now an unsaved instance of the Review model, rather than a form > (you should probably make tha

Re: Form cleaned_data

2013-11-25 Thread Daniel Roseman
On Sunday, 24 November 2013 18:46:21 UTC, Timothy W. Cook wrote: > > On Sun, Nov 24, 2013 at 4:38 PM, Daniel Roseman > > > wrote: > > Hmm, I tried to post an answer to your original question earlier but it > never appeared. > > > > Thanks Daniel. Your help is very much appreciated. > > > Th

Re: Form cleaned_data

2013-11-24 Thread Timothy W. Cook
On Sun, Nov 24, 2013 at 4:38 PM, Daniel Roseman wrote: > Hmm, I tried to post an answer to your original question earlier but it never > appeared. > Thanks Daniel. Your help is very much appreciated. > The reason why adding the values to `cleaned_data` doesn't work is that those > fields aren

Re: Form cleaned_data

2013-11-24 Thread Daniel Roseman
Hmm, I tried to post an answer to your original question earlier but it never appeared. The reason why adding the values to `cleaned_data` doesn't work is that those fields aren't in the `fields` list for the form in the first place, so it doesn't know to do anything with them. Adding them to t

Re: Form cleaned_data

2013-11-24 Thread Timothy W. Cook
SOLVED: (I think) Though I do not understand the how/why. From an example on StackOverflow I tried changing the post method to this: def post(self, request, *args, **kwargs): form = self.form_class(request.POST) if form.is_valid(): # paper = get_obj

Form cleaned_data

2013-11-24 Thread Timothy W. Cook
I have an issue with save data from a form. The actual form has one required and two optional fields. The model has three additional fields that I want to assign based on the context, two of those are ForeignKey related. The post method in the view: def post(self, request, *args, **kwargs):