I have tried every answer on the (Django script to access model objects without using manage.py shell) stack question, and I always get error "no module name 'project_name'". My project name is called snapbackend.
I have an __init__.py
setup. I know I can write django command, but that is somewhat overkill to run one function.
I am using django 2.0, and I wanted to write a script to delete old models.
import os
os.environ["DJANGO_SETTINGS_MODULE"] = "snapbackend.settings.production"
import django
django.setup()
import snapbackend
from snapbackend.models import deleteCapsuleModels
deleteCapsuleModels()