Originally created by @SerafimPikalov on GitHub (Dec 7, 2025).
The perform_update method in TransactionViewSet accesses serializer.data["pk"] which triggers unnecessary full serialization of the transaction object, then fetches the same object from the database again. This is inefficient and can cause issues in edge cases.
Steps to Reproduce:
Update any transaction via PATCH/PUT request to /api/transactions/{id}/
Observe the unnecessary serialization and database query in logs/debugger
Expected Behavior:
The update operation should use the instance directly from the serializer without triggering serialization or additional database queries.
Actual Behavior:
The code:
Triggers full serialization via serializer.data["pk"]
Fetches the object from database again using Transaction.objects.get(pk=...)
Creates unnecessary overhead and potential race conditions
Originally created by @SerafimPikalov on GitHub (Dec 7, 2025).
The `perform_update` method in `TransactionViewSet` accesses `serializer.data["pk"]` which triggers unnecessary full serialization of the transaction object, then fetches the same object from the database again. This is inefficient and can cause issues in edge cases.
Steps to Reproduce:
1. Update any transaction via PATCH/PUT request to `/api/transactions/{id}/`
2. Observe the unnecessary serialization and database query in logs/debugger
Expected Behavior:
The update operation should use the instance directly from the serializer without triggering serialization or additional database queries.
Actual Behavior:
The code:
1. Triggers full serialization via `serializer.data["pk"]`
2. Fetches the object from database again using `Transaction.objects.get(pk=...)`
3. Creates unnecessary overhead and potential race conditions
I will update the function to use self.get_object() which should be more efficient. Thank you!
@eitchtee commented on GitHub (Dec 7, 2025):
Dang, nice catch.
I will update the function to use `self.get_object()` which should be more efficient. Thank you!
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @SerafimPikalov on GitHub (Dec 7, 2025).
The
perform_updatemethod inTransactionViewSetaccessesserializer.data["pk"]which triggers unnecessary full serialization of the transaction object, then fetches the same object from the database again. This is inefficient and can cause issues in edge cases.Steps to Reproduce:
/api/transactions/{id}/Expected Behavior:
The update operation should use the instance directly from the serializer without triggering serialization or additional database queries.
Actual Behavior:
The code:
serializer.data["pk"]Transaction.objects.get(pk=...)@eitchtee commented on GitHub (Dec 7, 2025):
Dang, nice catch.
I will update the function to use
self.get_object()which should be more efficient. Thank you!