diff --git a/netbox_diode_plugin/api/serializers.py b/netbox_diode_plugin/api/serializers.py index df0c5fb..174104c 100644 --- a/netbox_diode_plugin/api/serializers.py +++ b/netbox_diode_plugin/api/serializers.py @@ -19,10 +19,16 @@ from netbox_diode_plugin.models import Setting -if version.parse(version.parse(settings.VERSION).base_version) >= version.parse("4.1"): +try: + if version.parse(version.parse(settings.VERSION).base_version) >= version.parse( + "4.1" + ): + from core.models import ObjectChange + else: + from extras.models import ObjectChange +except version.InvalidVersion: from core.models import ObjectChange -else: - from extras.models import ObjectChange + from ipam.api.serializers import IPAddressSerializer, PrefixSerializer from rest_framework import serializers from utilities.api import get_serializer_for_model diff --git a/netbox_diode_plugin/api/views.py b/netbox_diode_plugin/api/views.py index 173a97d..30b17ae 100644 --- a/netbox_diode_plugin/api/views.py +++ b/netbox_diode_plugin/api/views.py @@ -7,10 +7,13 @@ from django.conf import settings from packaging import version -if version.parse(settings.VERSION).major >= 4: +try: + if version.parse(settings.VERSION).major >= 4: + from core.models import ObjectType as NetBoxType + else: + from django.contrib.contenttypes.models import ContentType as NetBoxType +except version.InvalidVersion: from core.models import ObjectType as NetBoxType -else: - from django.contrib.contenttypes.models import ContentType as NetBoxType from django.core.exceptions import FieldError from django.db import transaction from django.db.models import Q diff --git a/netbox_diode_plugin/tables.py b/netbox_diode_plugin/tables.py index 05b20b3..c7b1215 100644 --- a/netbox_diode_plugin/tables.py +++ b/netbox_diode_plugin/tables.py @@ -8,10 +8,13 @@ from django.conf import settings from packaging import version -if version.parse(settings.VERSION).major >= 4: +try: + if version.parse(settings.VERSION).major >= 4: + from core.models import ObjectType as NetBoxType + else: + from django.contrib.contenttypes.models import ContentType as NetBoxType +except version.InvalidVersion: from core.models import ObjectType as NetBoxType -else: - from django.contrib.contenttypes.models import ContentType as NetBoxType from netbox.tables import BaseTable, columns from utilities.object_types import object_type_identifier, object_type_name