J0 / django-storage-supabase

Custom Storage Backend for Supabase + Django
MIT License
20 stars 2 forks source link
django python supabase

Django-Storage-Supabase(Alpha)

About

This project aims to provide a custom storage backend for Supabase Storage so that it can be used as /media storage. This project heavily references the S3/Google Custom Storage backend in Django-Storages

To do this we follow the specification provided by Django

Eventually, we hope that this can be integrated into the django-storages library and then write a blogpost/tutorial about it.

Usage Instructions

  1. pip3 install django-storage-supabase

  2. In settings.py set the following variables

DEFAULT_FILE_STORAGE = 'django_storage_supabase.supabase'
SUPABASE_API_KEY = ''
SUPABASE_URL = "https:<your-supabase-id>"
SUPABASE_ROOT_PATH = '/dir/'

You can then use the following to upload to your backend.

photo = models.FileField(
    upload_to='photos',
)

Here's a reference (WIP) example of how to use Supabase storage as a backend together with the rest of the Supabase libraries.

TODOs: