mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-29 11:56:25 -06:00
12596 review changes
This commit is contained in:
parent
2d367eec10
commit
19384f8f8c
@ -131,13 +131,11 @@ def get_annotations_for_serializer(serializer_class, fields_to_include=None):
|
|||||||
if field_name in fields_to_include and type(field) is RelatedObjectCountField:
|
if field_name in fields_to_include and type(field) is RelatedObjectCountField:
|
||||||
try:
|
try:
|
||||||
related_field = model._meta.get_field(field.relation).field
|
related_field = model._meta.get_field(field.relation).field
|
||||||
related_field_name = related_field.name
|
|
||||||
except FieldDoesNotExist:
|
except FieldDoesNotExist:
|
||||||
# Handle RelatedObjectCountField with no related_name given
|
# Handle RelatedObjectCountField with no related_name given
|
||||||
related_field = getattr(model, field.relation).field
|
related_field = getattr(model, field.relation).field
|
||||||
related_field_name = field_name
|
|
||||||
|
|
||||||
annotations[field_name] = count_related(related_field.model, related_field_name)
|
annotations[field_name] = count_related(related_field.model, related_field.name)
|
||||||
|
|
||||||
return annotations
|
return annotations
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user