1π
β
I think the problem is that django ModelChoiceField
uses the queryset
to store all possible choices. If you change your front end code to pass in an id
that isnβt in the queryset
, django would fail your validation.
An easy solution would be to just use Label.objects.all()
as the queryset for ModelChoiceField
, but change the front end based on what the other choice is. If you concern about security, you can write your own validation to double check on the correlation between trans_type
and model
.
π€Shang Wang
Source:stackexchange.com