1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Merge branch 'develop' into develop-2.10

This commit is contained in:
Jeremy Stretch
2020-10-09 13:48:29 -04:00
36 changed files with 255 additions and 85 deletions

View File

@ -1,4 +1,5 @@
import django_tables2 as tables
from django.contrib.contenttypes.fields import GenericForeignKey
from django.core.exceptions import FieldDoesNotExist
from django.db.models.fields.related import RelatedField
from django.urls import reverse
@ -64,7 +65,7 @@ class BaseTable(tables.Table):
field_path = column.accessor.split('.')
try:
model_field = model._meta.get_field(field_path[0])
if isinstance(model_field, RelatedField):
if isinstance(model_field, (RelatedField, GenericForeignKey)):
prefetch_fields.append('__'.join(field_path))
except FieldDoesNotExist:
pass