Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor: use Queryset.defer() in XFormViewSet#2996

Merged
kelvin-muchiri merged 2 commits intomainfrom
refactor-xform-viewset
Jan 16, 2026
Merged

refactor: use Queryset.defer() in XFormViewSet#2996
kelvin-muchiri merged 2 commits intomainfrom
refactor-xform-viewset

Conversation

@kelvin-muchiri
Copy link
Contributor

@kelvin-muchiri kelvin-muchiri commented Jan 15, 2026

Changes/Features implemented

  • Use Queryset.defer() in XFormViewSet since the fields to be deferred are fewer than the fields to be loaded. Makes the code neater and eliminates N+1 queries arising from a new field being added in the serializer and failing to be added in the viewset's Queryset.only()
  • Exclude all serializer fields by default. Explicitly define what fields should be exposed to avoid accidental exposure of fields that should not be exposed

Steps taken to verify this change does what is intended

  • QA

Side effects of implementing this change

None

Before submitting this PR for review, please make sure you have:

  • Included tests
  • Updated documentation

Closes #

@kelvin-muchiri kelvin-muchiri force-pushed the refactor-xform-viewset branch 2 times, most recently from 4b2342b to 66b1658 Compare January 15, 2026 12:55
Use Queryset.defer() in XFormViewSet since the fields to be deferred are fewer than the fields to be loaded. Also takes into account that new fields can be added to the serializer and forgotten to be added in Queryset.only()
Use exclude all by default policy for XForm's serializer fields. Explicitly define what fields should be exposed
@kelvin-muchiri kelvin-muchiri marked this pull request as ready for review January 15, 2026 13:19
@kelvin-muchiri kelvin-muchiri merged commit fd50864 into main Jan 16, 2026
14 checks passed
@kelvin-muchiri kelvin-muchiri deleted the refactor-xform-viewset branch January 16, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants