[Bug] Include the objects with org=None, while filtering serilaizer fileds based on the organization of an user
See original GitHub issue@nemesisdesign , @atb00ker with this line of code we are trying to filter out other ForeignKey
related field other than organization
field, based on the organization of a user, But mostly all of such fields has an option to create objects as shared org(organization=None). eg.:- templates, CA, etc… But this LOC only returns the object belonging to an organization, excluding the objects whose organization is set to None.
Will it not be better, if we include the shared objects along with these.
CC: @Purhan
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Django rest framework - filtering for serializer field
When products have rendered into remote client, each of product takes a filed with filtered data. For example, model may be like this....
Read more >Document how to handle permissions and filtering for related ...
I tried digging through the code, but I couldn't find an easy way to do this. Ideally, you should be able to call...
Read more >3.0 Announcement - Django REST framework
We now use the following: Field is the base class for all fields. It does not include any default implementation for either serializing...
Read more >Serializers - Django REST framework
Serializers allow complex data such as querysets and model instances to be converted to native Python datatypes that can then be easily ...
Read more >Aggregation | Django documentation
Any filter() (or exclude() ) applied to normal model fields will have the effect of constraining the objects that are considered for aggregation....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ManishShah120 yes sorry my suggestion pointed to the wrong class but I believe you can use almost the exact same code. Try to use “in” instead of chaining several “or”, the result is easier to read.
You’re looping over the organizations and chaining several “or”, but can be done simply by adding None to the
organization_filter
list. It should be possible to disable this since it’s not required in every serializer. Please follow the suggestion I’ve given above.@ManishShah120 @atb00ker @Purhan what do you think about something like the following: