Re: Possible to have dynamic drop down list in ModelForm?

2010-09-22 Thread derek
If you search this list and /or the web, you'll see a number of
examples on how to do this.

On Sep 19, 8:42 am, Andy  wrote:
> I have a model FieldReport that has, among other fields, these two
> fields:
>
> -country
> -city
>
> Both "country" and "city" are lists of choices.
>
> I want to have a form FieldReportForm as a ModelfForm based on the
> model FieldReport. I want to have "country" and "city" represented as
> drop down lists. Moreover, "city" should be a dynamic list based on
> the selected value of "country".
>
> For example, if someone selects the value "US" for "country", then
> "city" should be a list of US cities only, all cities in other
> countries shouldn't be loaded onto that list.
>
> Is this something that would work with Django's ModelForm? How would
> you implement something like this?
>
> Thanks.

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



Re: Possible to have dynamic drop down list in ModelForm?

2010-09-20 Thread Scott Gould
Two ways, both requiring javascript:

1. Populate the city dropdown via ajax on country change.
2. Have your template write javascript to do country->city lookups and
alter the contents of the city dropdown on country change.

On Sep 19, 2:42 am, Andy  wrote:
> I have a model FieldReport that has, among other fields, these two
> fields:
>
> -country
> -city
>
> Both "country" and "city" are lists of choices.
>
> I want to have a form FieldReportForm as a ModelfForm based on the
> model FieldReport. I want to have "country" and "city" represented as
> drop down lists. Moreover, "city" should be a dynamic list based on
> the selected value of "country".
>
> For example, if someone selects the value "US" for "country", then
> "city" should be a list of US cities only, all cities in other
> countries shouldn't be loaded onto that list.
>
> Is this something that would work with Django's ModelForm? How would
> you implement something like this?
>
> Thanks.

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



Possible to have dynamic drop down list in ModelForm?

2010-09-18 Thread Andy
I have a model FieldReport that has, among other fields, these two
fields:

-country
-city

Both "country" and "city" are lists of choices.

I want to have a form FieldReportForm as a ModelfForm based on the
model FieldReport. I want to have "country" and "city" represented as
drop down lists. Moreover, "city" should be a dynamic list based on
the selected value of "country".

For example, if someone selects the value "US" for "country", then
"city" should be a list of US cities only, all cities in other
countries shouldn't be loaded onto that list.

Is this something that would work with Django's ModelForm? How would
you implement something like this?

Thanks.

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