On 2/28/07, Jay <[EMAIL PROTECTED]> wrote:
>
> My application has companies and aircraft, where aircraft has a
> foreign key to a company. When a user is creating a trip, both a
> company and an aircraft can be selected from drop-down lists. I'd like
> to modify so that after the company is selected the choices for
> aircraft are only those aircraft that are associated with the company
> rather than the entire set. Ideas, please....


In admin:
class Trip(...):
    ....
    class Admin:
       js = ['/your/js/to/do/filter.js/']

http://www.djangoproject.com/documentation/model_api/#js

But if not for admin, you can do a similarly unobtrusive thing.  The
select element for the company will have an ID.  Hook the change event
on it and re-fill the aircraft select elm using the json results of a
xmlhttprequest to a custom view.

Check out django.core.serializers:
http://www.djangoproject.com/documentation/serialization/

If that warning scares you, check out django.utils.simplejson instead.  :)

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