Skip to content

Instantly share code, notes, and snippets.

@stnbu
Created September 3, 2018 23:09
Show Gist options
  • Save stnbu/26500cf8cbda0255e6b6ae5d6b06b261 to your computer and use it in GitHub Desktop.
Save stnbu/26500cf8cbda0255e6b6ae5d6b06b261 to your computer and use it in GitHub Desktop.
Using the Django ORM outside of the web framework
# I was able to just put this module alongside `models.py` and use `myapp.db.FooTable(**kwargs).save()` etc outside
# of the web framework. With no issues, so far.
import django
from .settings import *
from django.conf import settings
settings.configure(DATABASES=DATABASES)
django.setup()
from .models import *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment