Plugin Foreign Key Form Filter with DynamicModelChoiceField #9934
Unanswered
cslingerland
asked this question in
Q&A
Replies: 1 comment
-
It's appearing like this isn't possible. Is anyone able to confirm? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a field that I want to behave similarly to how the Device Types / Manufactures do in the form where when you choose a Manufacturer, the Device Type field is filtered.
My Relationship model has a foreign key into my Vendor model, and it also has a foreign key to IPAddress
My Vendor model has a foreign key to the Prefix model.
When creating a relationship, I'd like to filter what IPs are available to choose from based on the prefix that is assigned to the vendor. Is this possible or are the query_params not going to work that way with this level of nesting?
I am able to "manually" accomplish this by writing a custom Edit view and then filtering the query before passing it to the form as follows:
ipaddresses = IPAddress.objects.filter(address__net_host_contained=str(prefix.prefix))
I'd like to have similar functionality using the built-in netbox code. I'm open to suggestions.
Here's my stab at getting this to work but it's not functional.
Beta Was this translation helpful? Give feedback.
All reactions