mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #5217: Prevent erroneous removal of prefetched GenericForeignKey data from tables
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
* [#5199](https://github.com/netbox-community/netbox/issues/5199) - Change default LDAP logging to INFO
|
||||
* [#5201](https://github.com/netbox-community/netbox/issues/5201) - Fix missing querystring when bulk editing/deleting VLAN Group VLANs when selecting "select all x items matching query"
|
||||
* [#5206](https://github.com/netbox-community/netbox/issues/5206) - Apply user pagination preferences to all paginated object lists
|
||||
* [#5217](https://github.com/netbox-community/netbox/issues/5217) - Prevent erroneous removal of prefetched GenericForeignKey data from tables
|
||||
|
||||
---
|
||||
|
||||
|
@ -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.utils.safestring import mark_safe
|
||||
@ -63,7 +64,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
|
||||
|
Reference in New Issue
Block a user