simonw / django-plugin-datasette

Django plugin to run Datasette inside of Django
Apache License 2.0
6 stars 0 forks source link

django-plugin-datasette

PyPI Changelog Tests License

Run Datasette inside Django as a DJP plugin

Installation

First configure your Django project to use DJP. Be sure to configure your asgi.py file.

Then install this plugin in the same environment as your Django application.

pip install django-plugin-datasette

Usage

Once installed, /-/datasette/ will serve a Datasette instance that exposes the contents of any SQLite databases used by Django.

You will need to run Django using ASGI. One way to do that is with Uvicorn:

pip install uvicorn
uvicorn myproject.asgi:application

Warning: This will expose your entire Django database to anyone who visits /-/datasette/. The auth_user.password field is automatically redacted, but you should still take care that this does not expose any other sensitive information.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd django-plugin-datasette
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

python -m pytest