Hi, I have a working django site and I'm trying to run a standalone script over its data. I am following this article, but can't get it to work. I have tried two approaches:
1)
import sys, os
sys.path.append(os.path.abspath('..'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
from mysite.main.models import Image
#from main.models import Image #should work too
2)
import sys, os
sys.path.append(os.path.abspath('..'))
from django.core.management import setup_environ
from mysite import settings
#import settings #should work too
setup_environ(settings)
from mysite.main.models import Image
Both gives me "AttributeError: 'module' object has no attribute 'models'" raised from the module I am trying to import (main.models).
The script itself is located in the project root of a working site, with the "main" app properly installed and working. There should be no problem with settings or models.