Move nested API serializers to a separate file within each app #2115

Closed
opened 2025-12-29 17:22:25 +01:00 by adam · 0 comments
Owner

Originally created by @jeremystretch on GitHub (Nov 9, 2018).

Proposed Changes

Currently, all the API serializers within an app (e.g. dcim) reside in the same file at {app}/api/serializers.py. This causes issues with circular dependencies, where two primary serializers in different apps cross-reference nested serializers: Only one can be imported into the other. This requires duplicating nested serializers in some cases.

Justification

Moving all of the nested serializers into separate files from the primary serializers should avoid duplication, as they can all then be imported freely.

Note: This does not affect the API itself, merely how the code is organized.

Originally created by @jeremystretch on GitHub (Nov 9, 2018). ### Proposed Changes Currently, all the API serializers within an app (e.g. `dcim`) reside in the same file at `{app}/api/serializers.py`. This causes issues with circular dependencies, where two primary serializers in different apps cross-reference nested serializers: Only one can be imported into the other. This requires duplicating nested serializers in some cases. ### Justification Moving all of the nested serializers into separate files from the primary serializers should avoid duplication, as they can all then be imported freely. **Note:** This does not affect the API itself, merely how the code is organized.
adam added the status: acceptedtype: housekeeping labels 2025-12-29 17:22:25 +01:00
adam closed this issue 2025-12-29 17:22:25 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2115