Hi There,
For various reasons I recently started efforts to covert an existing .php application to pyhton + django.
There are quite a few scripts that are executed through cron and so from the command line while coding.
I did find some info on how to setup the start of the script, but keep running into an error I haven't been able to resolve so far.
Using Python 2.7.x and django 1.8.x + postresql
Script is starting with this:
---------------------- snip ----------------------
import os,sys
sys.path.append('/home/oscar/django/trading/myichimoku')
os.environ['DJANGO_SETTINGS_MODULE']='myichimoku.settings'
from models import MyichiTickers
---------------------- snip ----------------------
The script lives in /home/oscar/django/trading/myichimoku/data in which the models.py lives as well
The error I get:
---------------------- snip ----------------------
Traceback (most recent call last):
File "historic_data_collector.py", line 4, in <module>
from models import MyichiTickers
File "/home/oscar/django/trading/myichimoku/data/models.py", line 4, in <module>
class AuthGroup(models.Model):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 131, in __new__
'app.' % (new_class.__name__, model_module.__name__)
django.core.exceptions.ImproperlyConfigured: Unable to detect the app label for model "AuthGroup." Ensure that its module, "models", is located inside an installed app.
---------------------- snip ----------------------
AuthGroup is the 1st table class in models.py
My settings.py lives in: /home/oscar/django/trading/myichimoku/myichimoku/
Here a snippet from the file:
---------------------- snip ----------------------
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'data',
)
---------------------- snip ----------------------
So the question is: how can I ensure to execute this script from the command line with something like: python mycoolscript.py ?
Any help greatly appreciated.
Thanks!
Oscar