Skip to content

kdpisda/django-rls

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Django RLS

PyPI version PyPI - Downloads CI Documentation codecov Python Version Django Version License

A Django package that provides PostgreSQL Row Level Security (RLS) capabilities at the database level.

Features

  • 🔒 Database-level Row Level Security using PostgreSQL RLS
  • 🏢 Tenant-based and user-based policies
  • 🔧 Django 5.0, 5.1, and 5.2 (LTS) support
  • 🧪 Comprehensive test coverage
  • 📖 Extensible policy system
  • ⚡ Performance optimized

Quick Start

from django_rls.models import RLSModel from django_rls.policies import TenantPolicy, UserPolicy class TenantAwareModel(RLSModel): name = models.CharField(max_length=100) tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE) class Meta: rls_policies = [ TenantPolicy('tenant_policy', tenant_field='tenant'), ]

Installation

Install from PyPI:

pip install django-rls

Or install the latest development version:

pip install git+https://github.com/kdpisda/django-rls.git

Requirements

  • Python 3.10, 3.11, 3.12, or 3.13
  • Django 5.0, 5.1, or 5.2 (LTS)
  • PostgreSQL 12 or higher (tested with PostgreSQL 17)

Add to your Django settings:

INSTALLED_APPS = [ # ... your apps 'django_rls', ] MIDDLEWARE = [ # ... your middleware 'django_rls.middleware.RLSContextMiddleware', ]

Documentation

Full documentation is available at django-rls.com

Quick Links

License

BSD 3-Clause License - see LICENSE file for details.

About

Row Level Security for Django

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •