Repository: netbox-community/netbox
Pull request: Fixes: #18192 - Use assigned_object instead of interface in display_attrs
### Fixes: #18192

Uses `assigned_object` instead of `interface` in `MACAddressIndex.display_attrs`.

Problem statement:
Searching for a MAC address results in server error
### Deployment Type

Self-hosted

### Triage priority

N/A

### NetBox Version

v4.2-beta1

### Python Version

3.11

### Steps to Reproduce

1. Create a MAC address.
2. Search for it.

### Expected Behavior

Address shows up.

### Observed Behavior

```
<class 'AttributeError'>

'GenericRel' object has no attribute 'verbose_name'
```

Hints from issue discussion:

Commit message: Use assigned_object instead of interface in display_attrs

Patch to review:
diff --git a/netbox/dcim/search.py b/netbox/dcim/search.py
index 6b03d8b4367..740cb025383 100644
--- a/netbox/dcim/search.py
+++ b/netbox/dcim/search.py
@@ -105,7 +105,7 @@ class MACAddressIndex(SearchIndex):
         ('mac_address', 100),
         ('description', 500),
     )
-    display_attrs = ('mac_address', 'interface')
+    display_attrs = ('mac_address', 'assigned_object')
 
 
 @register_search


Code review comments:
diff_hunk: @@ -105,7 +105,7 @@ class MACAddressIndex(SearchIndex):
         ('mac_address', 100),
         ('description', 500),
     )
-    display_attrs = ('mac_address', 'interface')
+    display_attrs = ('mac_address', 'assigned_object')
path: netbox/dcim/search.py
text: @user1:
We can probably omit the MAC address itself, because it's already the primary representation of the object. Including it here is redundant (see below).

```suggestion
    display_attrs = ('assigned_object',)
```

![screenshot](https://github.com/user-attachments/assets/745a1688-8e92-4458-a380-81a5d488f6c8)


@author:
Ah, good to know. Added `description` too.