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

15532 fix autotype_decorator for method fields

This commit is contained in:
Arthur
2024-03-26 07:28:41 -07:00
committed by Jeremy Stretch
parent 379fe7c160
commit 815cab5c9a

View File

@ -4,6 +4,7 @@ from typing import List
import django_filters
import strawberry
import strawberry_django
from django.core.exceptions import FieldDoesNotExist
from strawberry import auto
from ipam.fields import ASNField
from netbox.graphql.scalars import BigInt
@ -164,7 +165,11 @@ def autotype_decorator(filterset):
should_create_function = False
attr_type = auto
if fieldname not in cls.__annotations__:
try:
field = model._meta.get_field(fieldname)
except FieldDoesNotExist:
continue
if isinstance(field, CounterCacheField):
should_create_function = True
attr_type = BigInt | None