I've found that this is a fairly common situation. For instance, Location 
has an FK to Company,
and then ManyToMany to StaffMember. But, only StaffMembers that have their 
FK set to
the same Company should be selectable in their inline.

This need not just be a ManyToMany thing, either. The Manager of a Location 
should also
be a StaffMember, but may only be one who is associated with the same 
Company.

This is one example: another, perhaps more common one, is Country & 
State/Province.

The available choices for a State/Province depend upon which Country is 
selected.

For the OP: the only way to do this requires JavaScript on the client end, 
and creating
views to return the limited set of objects you wish to be able to select 
from. When your
user changes Country, for instance, you then fetch the available list of 
States for that
country, and use that to populate the State field options.

I have an example (of exactly this) in my fork of django-countries: 
https://bitbucket.org/schinckel/django-countries/src

Specifically, have a look at the JS: 
https://bitbucket.org/schinckel/django-countries/src/0482ff867b4c/django_countries/static/countries/js/update_provinces_select.js

It's not especially well documented, and the JS only works for country 
field being 
called country, and province field being called province, but it might be a 
nice start for you
to see how to do it.


Matt.

-- 
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/-/qIbITxaVnUcJ.
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