Cool I resolved the error. So when you have a drop down list for an
IntegerField that is an optional IntegerField in the database, you
must set some sort of validation to tell this optional field to be
None (for the obvious reasons). What I didn't realize is when I had a
choices list set in the Choicefield which was optional, django puts in
a (("","----------"),) at the top of the list. So for others who might
have this problem make sure to set None to an optional IntegerField in
your model when validating or right before saving.

This is a general question to the Django Community? Should there be
some automation that realizes that it is a choices list for an
IntegerField and should not include this " " but should include this
None as the default blank field?




On May 15, 12:21 pm, Chris <[EMAIL PROTECTED]> wrote:
> Hi Karen,
>
> I have a form with first_name, last_name and email and once the user
> presses submit, it will then save the 3 required fields to the
> database and send the data to another form containing additional
> fields suchas year_of_birth, phone_number, address,city, state, etc...
> The 3 required fields have already been filled out by a user in the
> first form, the next form it sends data to contains optional fields. I
> am not using form wizard either, just a render_to_response that passes
> data to the next form. Why it works on my local dev and not on the
> company dev makes no sense.
>
> model field declaration looks like this:
>
>     year_of_birth = models.IntegerField(blank=True, null=True,
>         choices=YEAR_OF_BIRTH)
>
> also I I noticed when I take out the ChoicesField altogether it seems
> to process fine or if I change field to a textfield it works too.
>
> Thanks for helping me with this strange issue.
>
> Chris
>
> On May 15, 9:38 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > On Wed, May 14, 2008 at 6:14 PM, Chris <[EMAIL PROTECTED]> wrote:
>
> > > Hello I created a new forms form and I am having uses with this
> > > statement:
>
> > >    year_of_birth = forms.ChoiceField(required=False,
> > > choices=YEAR_OF_BIRTH)
>
> > > and tuple looks like so:
> > >    year_of_birth = ((1990, '1990'), (1989, '1989'), ...)
>
> > > On my local dev server, I have latest django and use sqllite, this
> > > works fine but when I push code to our company dev server and try to
> > > run code it, it breaks and give me the following message. On the
> > > company dev we use mysql. This almost looks like it could be a mysql
> > > specific bug but the error is so vague who knows. I don't understand
> > > how I can pass a tuple through and it think that I am giving it a ''
> > > value.
>
> > > Exception Type:         Warning
> > > Exception Value:        Incorrect integer value: '' for column
> > > 'year_of_birth' at row 1
> > > Exception Location:     /usr/lib/python2.5/site-packages/MySQLdb/
> > > cursors.py in _warning_check, line 80
>
> > > Could someone please help. This error is driving me crazy!
>
> > > Thanks in advance.
>
> > You don't mention when you get this error: all of the time, regardless of
> > the choice, only when the 'blank' choice is chosen, etc?  MySQL is
> > complaining that it is being handed and empty string to put in an integer
> > field.  I notice you have required=False on the form field, so I'd guess you
> > are seeing this only when the 'blank' choice is chosen, in which case I
> > suspect the fix would be to specify null=True in the model field, so that
> > blank will be stored as null in the database.
>
> > Karen
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to