Hello djangoics,
I'd like to ask for the opinion of some django veterans
on a task that I imagine to be a fairly common one.
My site allows the user to set a country and city
as part of their UserProfile. Obviously the city-field
should only allow values that are valid within the context
of the selected country ("France / Chicago" doesn't work).
I have hacked up a fairly naive implementation that involves
two CharFields, country and city, where the former refers to
a lengthy list of "choices" and the latter just relies on all forms
to be equipped with a custom constructor (to populate the options)
and validator (to deny invalid combinations). In the templates I'm
using the usual bit of a ajax trickery to populate the "city"
select-widget according to and after the country has been selected.
Now this works ok but it's a lot of ugly boilerplate code and
I'm convinced there must be a much more elegant way to solve
this all at the model level.
I have the country/city relation in the database already, so
it's just a matter of instrumenting it properly within django.
Can someone set me on the right track? :)
-mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---