Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Relationships do not show in dynamic filter forms #3345

Closed
jathanism opened this issue Feb 21, 2023 · 1 comment · Fixed by #3550
Closed

Custom Relationships do not show in dynamic filter forms #3345

jathanism opened this issue Feb 21, 2023 · 1 comment · Fixed by #3550
Assignees
Labels
type: bug Something isn't working as expected

Comments

@jathanism
Copy link
Contributor

jathanism commented Feb 21, 2023

Environment

  • Nautobot version (Docker tag too if applicable): 1.5.x
  • Python version: n/a
  • Database platform, version: demo.nautobot.com
  • Middleware(s):

Steps to Reproduce

  1. Create relationship with source content type dcim | device and destination ipam | VLAN
  2. Go to Device list view and click filter
  3. Try to find "VLANs"

Expected Behavior

The "VLANs" field for custom relationships.

Observed Behavior

It does not show and cannot be used as a filter. In fact, no relationships will show in the "advanced" view filter view. Default filter view they show up.

@jathanism jathanism added the type: bug Something isn't working as expected label Feb 21, 2023
@jathanism
Copy link
Contributor Author

jathanism commented Feb 21, 2023

It appears the issue is here:

lookup_field = re.sub(r"__\w+", "", lookup_type)

It has to do with the fact that cr filters are named with their destination e.g. cr_device_to_vlans__destination. And they appear to get filtered out incorrectly since it gets split into cr_device_to_vlans (which does not exist on the filter nor inner form fields). I would guess that custom relationships fields need to be excluded from this and other "split" logic.

There is some other logic that appears to be filtering out things with __ in their name as well in the form code:

if "__" not in name and name != "q"

@jathanism jathanism changed the title One-to-many Relationships do not show in dynamic filter forms Custom Relationships do not show in dynamic filter forms Feb 27, 2023
@bryanculver bryanculver self-assigned this Apr 8, 2023
bryanculver added a commit that referenced this issue Apr 10, 2023
- 🏎️ Do not evaluate the QuerySet on the FilterForm when we just need to see if one is set Relationship from/to object with big population makes object's list unusably slow  #2944
- 🏎️ Allow an instantiated FilterSet to be passed into machinery for DynamicFilterForm because often times we already have one but if you pass in a class (old behavior) instantiate it like we always were (empty). Saves time doing the Relationship lookups and processing 5 times ~Relationship from/to object with big population makes object's list unusably slow  #2944
-💡 Add support for Relationships on the DynamicFilterForm Custom Relationships do not show in dynamic filter forms #3345
- 🎨 Make the label on filters Relationships human-readable (missed in Show Filter Label, display for Field Choices for Active Filter Display #3010 because .label would need a side)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working as expected
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants