I want to update a form based on user selection of one field. Here is my models.py
models.py
class A(Model):
text = CharField()
class B(Model):
a = ForeignKeyField(A)
class C(Model):
a = ForeignKeyField (A)
b = ForeignKeyField(B)
Assuming we use ModelChoiceField in forms.py.
Now if a user is adding a C
object, and he selects an A
object, I want to populate B field with queryset=a.b_set
. Is there any way to do this in django? Or if I have to use Javascript, is there a best practice as to how to integrate this with django?
Thanks