Custom Permissions of Django Materialized View

23 views
Skip to first unread message

Will Meyers

unread,
Jun 10, 2020, 4:46:26 PM6/10/20
to Django users
Hi all,

I'm building an application that uses Django Rest Framework and Django Guardian. I have to implement a permissions system such that when a user requests data from a materialized view, I need to omit certain rows from the returned queryset based on the user's group. 

For example, if my app contains 5 models:
  • User Model
  • User Group Model
  • Source Model
  • Article Model (with manytomany to Source Model)
  • Article Materialized View (consists of a flat table with an array field for sources
If a user searches for articles, but because they belong to a certain group that doesn't allow the source "Example Source", the queryset would return articles from the materialized view that omit articles related to the source "Example Source".

The challenge I'm facing is that I had a permissions system in place for a normalized model, but since switching to materialized view (the denormalized model), I'm unsure how to go about implementing something like this.

Any help appreciated.

Best,

Will
Reply all
Reply to author
Forward
0 new messages