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