Repository: netbox-community/netbox
Pull request: Fixes: #18350 - Remove 'site' and 'provider_network' from CircuitTerminationIndex.display_attrs
### Fixes: #18350

As `CircuitTermination` has been refactored to move the fields `site` and `provider_network` to the new scoping model, this change uses the new internal (cached) versions of those fields in the displayed attributes in search results, resolving a crash condition.


Problem statement:
Global search which matches CircuitTermination results in "CircuitTermination has no field named 'site'"
### Deployment Type

Self-hosted

### Triage priority

I volunteer to perform this work (if approved)

### NetBox Version

v4.2.1

### Python Version

3.10

### Steps to Reproduce

Create at least one CircuitTermination where the `xconnect_id` field is populated
Global search for the value of that field


### Expected Behavior

Successful search result page with the CircuitTermination in question listed

### Observed Behavior

`FieldDoesNotExist`: `CircuitTermination has no field named 'site'`

Hints from issue discussion:

Commit message: Use '_site' and '_provider_network' in display_attrs

Patch to review:
diff --git a/netbox/circuits/search.py b/netbox/circuits/search.py
index 2ea11b7fd72..6ff49f2e6ed 100644
--- a/netbox/circuits/search.py
+++ b/netbox/circuits/search.py
@@ -34,7 +34,7 @@ class CircuitTerminationIndex(SearchIndex):
         ('port_speed', 2000),
         ('upstream_speed', 2000),
     )
-    display_attrs = ('circuit', 'site', 'provider_network', 'description')
+    display_attrs = ('circuit', '_site', '_provider_network', 'description')
 
 
 @register_search


Code review comments:
diff_hunk: @@ -34,7 +34,7 @@ class CircuitTerminationIndex(SearchIndex):
         ('port_speed', 2000),
         ('upstream_speed', 2000),
     )
-    display_attrs = ('circuit', 'site', 'provider_network', 'description')
+    display_attrs = ('circuit', '_site', '_provider_network', 'description')
path: netbox/circuits/search.py
text: @user1:
We need to ensure that all scope types are supported (not just site and provider network). To do this, we can reference the `termination` GFK rather than the individual ForeignKey assignments.

```suggestion
    display_attrs = ('circuit', 'termination', 'description')
```

This will return whichever type of related object is assigned:

![screenshot](https://github.com/user-attachments/assets/02bab88c-01a0-4656-9a6e-b235e5fa330f)


@author:
Agreed, that's much nicer.