Asked 11 months ago by GalacticScout260
How can I dynamically update ModelChoiceField querysets based on user input in Django?
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Asked 11 months ago by GalacticScout260
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Hi all,
I need help dynamically updating the queryset of one ModelChoiceField based on the value selected in another ModelChoiceField (and possibly other input fields). For example, I have two ModelChoiceFields defined as follows:
PYTHONassigned1Id = forms.ModelChoiceField(queryset=models.User.objects.all().filter(status=True), empty_label="Name") assigned2Id = forms.ModelChoiceField(queryset=models.Properties.objects.all().filter(status=True), empty_label="Properties")
I want the following behavior:
This dynamic updating should also be applicable to other input fields (such as a CharField) where entering a value would filter the properties list in the ModelChoiceField.
Is this possible? Any guidance or examples of how to achieve this would be greatly appreciated. Thank you!
Comments 0
•Answers 0
•Views 75
No comments yet.