I have 3 models as such:
class Customer (models.Model):
name = models.CharField (max_length = 20)
class Vehicle (models.Model):
make = models.CharField (max_length = 20)
customer = models.ForeignKey(Customer)
class Appointment (models.Model):
customer = models.ForeignKey (Customer)
vehicle = models.ForeignKey (Vehicle)
In the Appointment admin site, it currently shows me two dropdown lists, one showing all customers and the other showing all vehicles.
I want to implement it such that I first pick a customer, and then the second dropdown list is populated with a list of vehicles the customer owns. I know how to do this in a standard template with jQuery, but I can’t find any documentation about how to do this in the admin site.
https://github.com/digi604/django-smart-selects
EDIT: There’s also a small app which provides a widget that you can use in django admin, and which doesn’t require changes to the model (ChainedForeignKey etc.).
https://github.com/runekaagaard/django-admin-flexselect