django-user-permissions for Django REST Framework

A while back I was working on a document management feature. Users could create documents, but naturally they should only be able to edit or delete their own. Managers, on the other hand, needed broader access so they could edit any document within their department. And then there were reports that had to be publicly readable by anyone, even without logging in. Django’s built-in permissions work well when things are global, like saying “managers can edit all documents”. But the moment you step into real-world rules like “this user can only edit their own documents” or “this specific person can access this one record”, you end up writing custom checks everywhere. It quickly becomes repetitive and a bit fragile. I kept running into the same problems, so I wanted something cleaner and reusable for: - Per-object permissions for individual records - Automatic ownership rules (users managing their own content) - Public access for specific endpoints without authentication - DRF action mapping so permissions are consistent across endpoints - Permission caching to avoid unnecessary database hits on every request Yes, django-guardian exists – but it's heavy and requires extra wiring for DRF. I wanted something lighter, DRF‑native, and drop‑dead simple. That is what led me to build django-user-permissions, a lightweight package that plugs into Django REST Framework. It gives you a simple mixin for viewsets, a way to attach permissions directly to objects, and a few controls for ownership and public access. The idea was not to build another heavy role system, but to fill in the gaps Django leaves at the object level. If you have ever had to implement “edit only your own posts” or “share a single private document with someone”, you probably know how quickly this logic spreads across a codebase. This is just my attempt to keep that part of Django a bit more manageable. 📦 PyPI: [https://lnkd.in/gR63kZdB) 💻 GitHub: https://lnkd.in/geSY5Mfj pip install django-user-permissions #Django #DRF #Python #OpenSource #Permissions

  • graphical user interface, text, application, email

does it work similar as guardian?

Like
Reply

To view or add a comment, sign in

Explore content categories