Django ORM as a standalone library

This works:

import os 
import django 

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
django.setup()

# And you're good... 

You can do settings.configure() if you don’t want to provide the settings module.

I hope that helps.

1 Like