1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4690],{33475:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/100-words/day-248",function(){return n(18616)}])},18616:function(e,t,n){"use strict";n.r(t),n.d(t,{meta:function(){return r}});var o=n(85893),i=n(11151),s=n(53841);let r={author:"Andrew Miller",date:"2024-12-20",title:"Filtering lists using perimssions",description:"",tags:["100 words","django","permissions","guardian","object-level"]},MDXLayout=e=>(0,o.jsx)(s.B,Object.assign({meta:r},e));function _createMdxContent(e){let t=Object.assign({p:"p"},(0,i.ah)(),e.components);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(t.p,{children:"Continuing from yesterday, the point of this architecture choice is simplify the codebase and align the logic across multiple models, forms and views. However if it doesn't work for the features we need then I'm not against adopting more usual patterns and packages to get the job done (ie django-taggit for tagging/filtering)."}),"\n",(0,o.jsx)(t.p,{children:"Before we get into how the filtering works, there is a slight correction from yesterday. It turns out Django Guardian is using a Generic Foreign Key under the hood to link everything together. What's nice is the shortcut functions they provide and obviously the integration with the permissions framework."}),"\n",(0,o.jsx)(t.p,{children:"Back on filtering, it is slightly harder to wrap my head around which models we need to perform the filter on. However having the consistent language of the permissions and content type apps means some shortcut functions are now easy to use and hide most of the complexity. The next hurdle at some point is going to be searching these objects, hopefully by then I will have a polymorphic base model implemented to ease that solution!"})]})}t.default=function(e={}){return(0,o.jsx)(MDXLayout,Object.assign({},e,{children:(0,o.jsx)(_createMdxContent,e)}))}}},function(e){e.O(0,[407,8819,4825,9774,2888,179],function(){return e(e.s=33475)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.