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
1 changed files with 6 additions and 1 deletions

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__:
field = model._meta.get_field(fieldname)
try:
field = model._meta.get_field(fieldname)
except FieldDoesNotExist:
continue
if isinstance(field, CounterCacheField):
should_create_function = True
attr_type = BigInt | None