#!/usr/bin/env python import os os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' import django django.setup() from app.models import Class # Your scripting here.
Sources:
https://docs.djangoproject.com/en/1.10/intro/tutorial02/#playing-with-the-api
https://docs.djangoproject.com/en/1.10/topics/settings/#on-the-server-mod-wsgi