Skip to content

Commit

Permalink
Fixes #17124: BaseTable should follow reverse one-to-one relationship…
Browse files Browse the repository at this point in the history
…s when prefetching related objects
  • Loading branch information
jeremystretch committed Aug 10, 2024
1 parent 20967bf commit 9c7002f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion netbox/netbox/tables/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.contrib.contenttypes.fields import GenericForeignKey
from django.core.exceptions import FieldDoesNotExist
from django.db.models.fields.related import RelatedField
from django.db.models.fields.reverse_related import ManyToOneRel
from django.urls import reverse
from django.urls.exceptions import NoReverseMatch
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -102,7 +103,7 @@ def __init__(self, *args, user=None, **kwargs):
field = model._meta.get_field(field_name)
except FieldDoesNotExist:
break
if isinstance(field, RelatedField):
if isinstance(field, (RelatedField, ManyToOneRel)):
# Follow ForeignKeys to the related model
prefetch_path.append(field_name)
model = field.remote_field.model
Expand Down

0 comments on commit 9c7002f

Please sign in to comment.