Skip to content Skip to sidebar Skip to footer

Atom `script` Add-on Doesn't Recognize Django Model/settings When Running A Script

It seems I run into some dependencies issues when trying to run a python script within my Django based web application using the atom add-on script. I would like to run the followi

Solution 1:

Your models are inside your apps, and your apps are inside your settings (INSTALLED_APPS), so you should configure the django's settings before you can access them.

Just add these beforeimporting your models:

import django
django.setup()

You should also set DJANGO_SETTINGS_MODULE environment varialbe to specify your settings file; or use django.configure if you prefer (docs).

Post a Comment for "Atom `script` Add-on Doesn't Recognize Django Model/settings When Running A Script"