Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion ModelForms and ForeignKeys causing ValueError
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Bengtsson  
View profile  
 More options Jun 16 2010, 9:42 am
From: Peter Bengtsson <pete...@gmail.com>
Date: Wed, 16 Jun 2010 06:42:12 -0700 (PDT)
Local: Wed, Jun 16 2010 9:42 am
Subject: Re: ModelForms and ForeignKeys causing ValueError
Submitted here: http://code.djangoproject.com/ticket/13776

On Jun 14, 2:05 pm, Karen Tracey <kmtra...@gmail.com> wrote:

> On Mon, Jun 14, 2010 at 12:39 PM, Peter Bengtsson <pete...@gmail.com> wrote:
> > I'm happy to submit a ticket but wanted to check first that I'm doing
> > the right thing. I think this used to work in Django 1.1 but not now
> > in trunk.

> > I can better explain it with code:

> > [snip details]
> > The point of this is that I can make an advanced search form where the
> > form is just like the form for added one of these models. In my view I
> > never call the save() method of the form instance.

> > # tests.py
> > class SimpleTest(TestCase):
> >    def test_model_forms(self):
> >        from forms import FooBarForm
> >        post = {'name':'Peter'}
> >        f2 = FooBarForm(data=post)
> >        self.assertTrue(not f2.is_valid())

> > Instead of returning False on the is_valid() function, it raises a
> > ValueError which looks like this:

> > [snip details]

> > I can understand that the field doesn't like having None set as a
> > value because it will never allow the save but I'm not interested in
> > saving here. I'm interested in getting a form that models (no pun
> > intended) itself on a model.

> > So, bug or feature?

> Looks like a bug to me. is_valid() ought not be raising a ValueError...worst
> case it should return False. But in this case True would seem to be the
> correct answer, since you've set the field to not required.

> Karen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.