Hi,
given the following model field:
room_setup = models.ForeignKey("roomsetup", verbose_name='Default room setup', blank=True, null=True, default='')
In the modelform __init__ method I'm setting the choices for this field like this:
self.fields['room_setup'].choices = roomsetups_as_choices(subevt)
def roomsetups_as_choices(subevt):
rs = [['', '-----']]
for setup in roomsetup.objects.filter(Q(subevent__isnull=True) | Q(subevent=subevt)):
rs.append([setup.id, setup.name])
return rs
When adding a new record I keep getting the following validation message, but only for the first try to submit of the form:
"Select a valid choice. That choice is not one of the available choices."
It passes without error on the second try... I really don't understand why?
IMHO it should not complain at all...
Any ideas?
Thomas
-- given the following model field:
room_setup = models.ForeignKey("roomsetup", verbose_name='Default room setup', blank=True, null=True, default='')
In the modelform __init__ method I'm setting the choices for this field like this:
self.fields['room_setup'].choices = roomsetups_as_choices(subevt)
def roomsetups_as_choices(subevt):
rs = [['', '-----']]
for setup in roomsetup.objects.filter(Q(subevent__isnull=True) | Q(subevent=subevt)):
rs.append([setup.id, setup.name])
return rs
When adding a new record I keep getting the following validation message, but only for the first try to submit of the form:
"Select a valid choice. That choice is not one of the available choices."
It passes without error on the second try... I really don't understand why?
IMHO it should not complain at all...
Any ideas?
Thomas
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/538a91aa-65b4-4465-8533-a21989bbcd11%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment