You could try using initial=0.

/J

On Tuesday, April 13, 2010, geraldcor <gregco...@gmail.com> wrote:
> Hello all,
>
> I know the error "invalid literal for int() with base 10: '' " has
> been discussed a lot in the past, but this seems to be unique to my
> situation.
>
> I have 2 choice fields as defined below for both the model and form:
>
> models.py
> class Checkin(models.Model):
> ...
> content = models.IntegerField(db_column='Content', blank=True,
> default=0)
> specie = models.IntegerField(db_column='Specie', blank=True,
> default=0)
> (I have tried a few variations on default and null=True etc)
> (This is accessing a legacy database)
>
> forms.py
> CONTENT_CHOICES=(
>         (2, 'IDFB USA Method'),
>         (5, 'IDFB ADFC Official'),
>         (7, 'IDFB Canada Method'),
>         (8, 'IDFB Australian Method'),
>         (9, 'General Report Format'),
>         (3, 'European Method'),
>         (4, 'Japanese Method'),
>         (6, 'California Method'),
>         (10, 'GB/T (Chinese)'),
> )
> SPECIES_CHOICES=(
>         (4, 'Down'),
>         (5, 'Feather'),
>         (6, 'Down and Feather'),
>         (7, 'Pre-Down'),
>         (8, 'Pre-Feather'),
>         (9, 'Pre-Down and Feather'),
> )
> class CheckinForm(ModelForm):
> ...
> content = forms.ChoiceField(required=False, choices=CONTENT_CHOICES,
> widget=forms.RadioSelect())
> specie = forms.ChoiceField(required=False, choices=SPECIES_CHOICES,
> widget=forms.RadioSelect())
>
> When I try to save the form and I do not select anything for these two
> fields I get the above error and the two fields are not listed in the
> POST area of the Request Information section of the error page.
> However, if I select something for each of those tests, the form saves
> just fine and all is well. I am using MySQL and the fields are INT(10)
> Default Value 0 or Null (I've tried both) and Not Null has been
> selected and not selected just for testing.
>
> I assume the problem has something to do with trying to save an empty
> string in an INT field, but my checkboxes that are unselected do not
> raise errors and the only thing different is that they are TINYINT(1).
> Any ideas on why this is happening. I'm trying to give as much info
> without being too verbose. I will post more if needs be.
>
> Thanks for all help both past and future.
>
> Greg
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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

Reply via email to