Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Error in form validation with choices [RSS Feed]

#1 May 18, 2010 20:49:41

J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Error in form validation with choices


Hi,

I upgraded one of my projects to 1.2 today. I noticed that one of my
model forms won't validate anymore:

class Review(Entry):
RATING_VALUE_CHOICES = (
('1', _('1. Overpriced')),
('2', _('2. Prices above average')),
('3', _('3. Average price range')),
('4', _('4. Inexpensive')),
('5', _('5. Excellent value')),
)

communication = models.IntegerField(max_length=1,
choices=RATING_COMMUNICATION_CHOICES, verbose_name =
_('communication'), help_text=_('i.e. customer service, order
confirmations'))
.......

And yes this is a child model inheriting model Entry (plain multi-
table inheritance). The Entry model has also one IntegerField with
choices and it works just fine. My form is created using ModelForm
without any custom stuff and this also gives error under admin ("Value
2 is not a valid choice.").

Anyone else having the same problem?

-Jori

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 May 18, 2010 20:53:28

J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Error in form validation with choices


Uups, copypasted the wrong choices list. The format is the same so
don't mind the variable name.

On May 18, 10:49 pm, Jori <jtla...@gmail.com> wrote:
> Hi,
>
> I upgraded one of my projects to 1.2 today. I noticed that one of my
> model forms won't validate anymore:
>
> class Review(Entry):
>     RATING_VALUE_CHOICES = (
>         ('1', _('1. Overpriced')),
>         ('2', _('2. Prices above average')),
>         ('3', _('3. Average price range')),
>         ('4', _('4. Inexpensive')),
>         ('5', _('5. Excellent value')),
>     )
>
>     communication = models.IntegerField(max_length=1,
> choices=RATING_COMMUNICATION_CHOICES, verbose_name =
> _('communication'), help_text=_('i.e. customer service, order
> confirmations'))
>     .......
>
> And yes this is a child model inheriting model Entry (plain multi-
> table inheritance). The Entry model has also one IntegerField with
> choices and it works just fine. My form is created using ModelForm
> without any custom stuff and this also gives error under admin ("Value
> 2 is not a valid choice.").
>
> Anyone else having the same problem?
>
> -Jori
>
> --
> 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
> athttp://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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 May 18, 2010 21:03:49

Daniel R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Error in form validation with choices


On May 18, 8:49 pm, Jori <jtla...@gmail.com> wrote:
> Hi,
>
> I upgraded one of my projects to 1.2 today. I noticed that one of my
> model forms won't validate anymore:
>
> class Review(Entry):
>     RATING_VALUE_CHOICES = (
>         ('1', _('1. Overpriced')),
>         ('2', _('2. Prices above average')),
>         ('3', _('3. Average price range')),
>         ('4', _('4. Inexpensive')),
>         ('5', _('5. Excellent value')),
>     )
>
>     communication = models.IntegerField(max_length=1,
> choices=RATING_COMMUNICATION_CHOICES, verbose_name =
> _('communication'), help_text=_('i.e. customer service, order
> confirmations'))
>     .......
>
> And yes this is a child model inheriting model Entry (plain multi-
> table inheritance). The Entry model has also one IntegerField with
> choices and it works just fine. My form is created using ModelForm
> without any custom stuff and this also gives error under admin ("Value
> 2 is not a valid choice.").
>
> Anyone else having the same problem?
>
> -Jori
>

It's an integer field, but the choices are all strings. The first
value in each tuple should be an integer, to match the field.
--
DR.

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 May 18, 2010 21:39:04

J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Error in form validation with choices


Thanks, you're correct. I don't know how I didn't notice but then
again it worked just fine with 1.1.1.

-Jori

On May 18, 11:03 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
>
> It's an integer field, but the choices are all strings. The first
> value in each tuple should be an integer, to match the field.
> --
> DR.
>
> --
> 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
> athttp://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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 June 7, 2010 06:52:30

Kieran F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Error in form validation with choices


I just ran into this as well. Very odd that earlier versions didn't
raise the same error.


On May 18, 1:38 pm, Jori <jtla...@gmail.com> wrote:
> Thanks, you're correct. I don't know how I didn't notice but then
> again it worked just fine with 1.1.1.
>
> -Jori
>
> On May 18, 11:03 pm, Daniel Roseman <dan...@roseman.org.uk> wrote:
>
>
>
> > It's an integer field, but the choices are all strings. The first
> > value in each tuple should be an integer, to match the field.
> > --
> > DR.
>
> > --
> > 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
> > athttp://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
> athttp://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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#6 June 14, 2010 00:47:38

R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Error in form validation with choices


Thanks for starting this thread ... just hit this myself porting to
1.2.1 from 1.1.1 ...

On May 18, 4:38 pm, Jori <jtla...@gmail.com> wrote:
> Thanks, you're correct. I don't know how I didn't notice but then
> again it worked just fine with 1.1.1.
>
> -Jori

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Error in form validation with choices [RSS Feed]

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support