Re: a recent update broke form.save(commit=False) on FK fields

2008-07-01 Thread omat

I have submitted a ticket for the issue:
http://code.djangoproject.com/ticket/7585


Thanks...


On Jul 1, 12:51 pm, omat <[EMAIL PROTECTED]> wrote:
> More specifically, I think the problem is in
> ReverseSingleRelatedObjectDescriptor in related.py, where it does not
> check if commit=False at line 249:
>
> ...
> if value is None and self.field.null == False:
> raise ValueError('Cannot assign None: "%s.%s" does not
> allow null values.' %
> (instance._meta.object_name,
> self.field.name))
> ...
>
> On Jul 1, 12:30 pm, omat <[EMAIL PROTECTED]> wrote:
>
> > But it is raised at the line:
>
> > photo = form.save(commit=False)
>
> > On Jul 1, 12:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> > wrote:
>
> > > On Tue, 2008-07-01 at 02:18 -0700, omat wrote:
> > > > Hi,
>
> > > > I updated Django to svn trunk v. 7811 from about a week old version.
>
> > > > When saving a form (ModelForm instance) with a foreign key to another
> > > > model, this used to work:
>
> > > > photo = form.save(commit=False)
> > > > photo.album = album
> > > > photo.save()
>
> > > > But now it raises a ValueError at the form.save(commit=False):
>
> > > > ValueError: Cannot assign None: "Photo.album" does not allow null
> > > > values.
>
> > > This error suggests the "album" is None. Django raises an error for that
> > > situation now (since it always was an error). So you need to investigate
> > > why "album" would be None there.
>
> > > That change was checked in on June 5 (it was r7574).
>
> > > Regards,
> > > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: a recent update broke form.save(commit=False) on FK fields

2008-07-01 Thread omat

More specifically, I think the problem is in
ReverseSingleRelatedObjectDescriptor in related.py, where it does not
check if commit=False at line 249:

...
if value is None and self.field.null == False:
raise ValueError('Cannot assign None: "%s.%s" does not
allow null values.' %
(instance._meta.object_name,
self.field.name))
...




On Jul 1, 12:30 pm, omat <[EMAIL PROTECTED]> wrote:
> But it is raised at the line:
>
> photo = form.save(commit=False)
>
> On Jul 1, 12:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
>
> > On Tue, 2008-07-01 at 02:18 -0700, omat wrote:
> > > Hi,
>
> > > I updated Django to svn trunk v. 7811 from about a week old version.
>
> > > When saving a form (ModelForm instance) with a foreign key to another
> > > model, this used to work:
>
> > > photo = form.save(commit=False)
> > > photo.album = album
> > > photo.save()
>
> > > But now it raises a ValueError at the form.save(commit=False):
>
> > > ValueError: Cannot assign None: "Photo.album" does not allow null
> > > values.
>
> > This error suggests the "album" is None. Django raises an error for that
> > situation now (since it always was an error). So you need to investigate
> > why "album" would be None there.
>
> > That change was checked in on June 5 (it was r7574).
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: a recent update broke form.save(commit=False) on FK fields

2008-07-01 Thread omat

But it is raised at the line:

photo = form.save(commit=False)



On Jul 1, 12:26 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Tue, 2008-07-01 at 02:18 -0700, omat wrote:
> > Hi,
>
> > I updated Django to svn trunk v. 7811 from about a week old version.
>
> > When saving a form (ModelForm instance) with a foreign key to another
> > model, this used to work:
>
> > photo = form.save(commit=False)
> > photo.album = album
> > photo.save()
>
> > But now it raises a ValueError at the form.save(commit=False):
>
> > ValueError: Cannot assign None: "Photo.album" does not allow null
> > values.
>
> This error suggests the "album" is None. Django raises an error for that
> situation now (since it always was an error). So you need to investigate
> why "album" would be None there.
>
> That change was checked in on June 5 (it was r7574).
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: a recent update broke form.save(commit=False) on FK fields

2008-07-01 Thread Malcolm Tredinnick


On Tue, 2008-07-01 at 02:18 -0700, omat wrote:
> Hi,
> 
> I updated Django to svn trunk v. 7811 from about a week old version.
> 
> When saving a form (ModelForm instance) with a foreign key to another
> model, this used to work:
> 
> photo = form.save(commit=False)
> photo.album = album
> photo.save()
> 
> 
> But now it raises a ValueError at the form.save(commit=False):
> 
> ValueError: Cannot assign None: "Photo.album" does not allow null
> values.

This error suggests the "album" is None. Django raises an error for that
situation now (since it always was an error). So you need to investigate
why "album" would be None there.

That change was checked in on June 5 (it was r7574).

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



a recent update broke form.save(commit=False) on FK fields

2008-07-01 Thread omat

Hi,

I updated Django to svn trunk v. 7811 from about a week old version.

When saving a form (ModelForm instance) with a foreign key to another
model, this used to work:

photo = form.save(commit=False)
photo.album = album
photo.save()


But now it raises a ValueError at the form.save(commit=False):

ValueError: Cannot assign None: "Photo.album" does not allow null
values.


--
omat
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---