On 12/27/06, Jason Barrett Prado <[EMAIL PROTECTED]> wrote:
Is this even possible, or is it not implemented correctly yet? I have done
every last thing I can think of that makes any sense and the results are
never what I want.

    if not request.POST.has_key('submit'):
        s = get_object_or_404(School, pk=school_name)
        f = UserRegistrationForm()
        f.fields['house'].widget.choices = [('test','test')]
        return render_to_response(' register.html', {'reg_form':f})
    f = UserRegistrationForm(data=request.POST)
    f.fields['house'].widget.choices = [('test','test')]
    if not f.is_valid():
        return render_to_response(' register.html', {'reg_form':f})

I fill in the form and POST it and it tells me that 'test' is not a valid
response for house. Why? I can call clean and full_clean on the data after
changing the choices, but it doesn't help. How should one do this?

I'm not quite sure what you're trying to do here, but my immediate
answer is: Don't set the choices on the Widget. Set the choices on the
Field. You're getting the validation error because the *Field* does
validation, not the Widget, and a Field has to know what its valid
choices are in order to do validation correctly.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
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