How are you populating the choices in the ChoiceField? Remember, you need 
to do this on BOTH the POST AND the non-POST versions of creating the form.

But ChoiceField is a Form field, not a Model field... so its not perfectly 
clear what you're asking.


On Tuesday, December 11, 2012 3:39:48 AM UTC-8, siddharth56660 wrote:
>
> Hi, 
>
> I am facing problem in handling modelform and ajax together. 
> The situation is:- 
> I am using modelform to get display the form as ul in the template. 
> I have 3 ChoiceFields (country, state,city). On select of a country 
> from the dropdown, the valid states dropdown gets populated and on 
> select of a state the respective city dropdown gets populated. 
> For achieving the above functionality I am calling an ajax function 
> which returns me the available data of the other dropdown in Json Form 
> {stat_id, stat_name} 
> I am able to populate the data in next dropdown i.e state and city, 
> but when i click submit form it shows "Select a valid choice. 8 is not 
> one of the available choices" 
> 8 happens to be the stat_id in this case. 
> I have gone through google but dint find anything useful. Help is 
> really appreciated. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/NEBq73A9EyEJ.
To post to this group, send email to django-users@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