Skip to content

Conversation

@BelpHegoR17
Copy link

This pull request fixes the issue described in #319.
The FilterSerializerByOrganization mixin was applying organization-based filtering to every serializer field that exposed a queryset, regardless of whether the related model actually contained an organization relation.This behavior was inconsistent with the expected logic of the mixin and caused unintended filtering in modules where certain related models are not tied to organizations.

This patch ensures that queryset filtering is applied only to fields whose related model actually contains an organization relation.Fields that do not have such a relation are left untouched.The behavior for fields pointing directly to the Organization model remains unchanged, and the existing include_shared logic and filtering rules for non-superusers continue to work as before.

Fixes #319.

…rganization openwisp#319

FilterSerializerByOrganization was incorrectly applying organization-based queryset filtering to serializer fields whose related models do not contain an organization relation. This caused incorrect queryset results.

This patch ensures that filtering applies only to models that actually have an organization field and preserves existing included_shared behaviour for superusers.

Fixes openwisp#319
@BelpHegoR17 BelpHegoR17 marked this pull request as draft December 3, 2025 08:09
@BelpHegoR17 BelpHegoR17 marked this pull request as ready for review December 3, 2025 08:09
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.

[bug] FilterSerializerByOrganization filters fields without organization

1 participant