Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions turbodrf/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def get_serializer_class(self):
else:
fields_to_use = fields

if self.action not in ["list", "detail", "retrieve"]:
fields_to_use = "__all__"
Comment on lines +195 to +196
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic unconditionally overrides fields_to_use for all non-read actions, ignoring the previously calculated field configuration from lines 182-193.

Looking at lines 186-189, the code already handles write operations (create, update, partial_update) by using the detail fields configuration, which is the appropriate behavior. This new code will override that logic and force __all__ fields for these operations.

Additionally, the condition excludes "detail" but not "retrieve", which are typically equivalent actions in DRF. This inconsistency is problematic because:

  1. "retrieve" is the standard DRF action name for getting a single object
  2. "detail" is not a standard DRF action name

This will break the existing field configuration logic for models that define different fields for list and detail views (like SampleModel in the tests). For write operations, this might expose fields that should only be visible in detail views, or force all model fields to be serialized when only a subset was intended.

Suggested change
if self.action not in ["list", "detail", "retrieve"]:
fields_to_use = "__all__"

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the point to show all the fields that are defined in turbodrf @copilot


# Store original fields before processing
original_fields = (
fields_to_use if isinstance(fields_to_use, list) else fields_to_use
Expand Down