here is the 'run.sh' I've created. Hope it helps. Now, to run a cron job, say 'cleanup.py', you will only need to do 'run.sh cleanup.py'.
%<-------------------------------- #!/bin/bash export PYTHONPATH="$PYTHONPATH:/lib/python2.4/site-package/django/:/ home/alex/projects/" export DJANGO_SETTINGS_MODULE="looker.settings" python $1 -------------------------------------->% HTH, Alex On Apr 12, 8:46 am, "Alex Dong" <[EMAIL PROTECTED]> wrote: > Thanks many. It works like a charm now. > > Alex > > On Apr 12, 12:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: > > > I am assuming that "looker" is the name of your project directory. > > When you use the statement "from looker...", python is searching > > through its search path and looking for either modules (python files) > > or packages (modules grouped in a directory containing an __init__.py > > file) called "looker". You had the right idea of appending the > > project path to the python search path, but you went one directory too > > deep. Try: > > PROJECT_PATH="~/projects" > > That way, when python is trying to resolve "looker", it will arrive at > > ~/projects, see a directory called "looker", happily find that it is > > indeed a python package via the presence of __init__.py (assuming you > > created your django project the standard way), and will then be able > > to import the settings module from the looker package. > > > On Apr 11, 3:57 am, "Alex Dong" <[EMAIL PROTECTED]> wrote: > > > > I'm having a bunch of cron jobs which will use django model and > > > send_mail features. I've read through this > > > linkhttp://groups.google.com/group/django-users/browse_thread/thread/5182... > > > but for some unknown reason, I still can't use django's model. > > > > Will anyone kindly look through my code and point out where I've done > > > wrong? > > > > %>-------------------------- > > > $ cat environ.py > > > #!/usr/bin/env python > > > > import sys > > > import os > > > from local_conf import * > > > > DJANGO_PATH = "/lib/python2.4/site-packages/django/" > > > PROJECT_PATH = "~/projects/looker" > > > PROJECT_SETTING = "looker.settings" > > > > sys.path.append(DJANGO_PATH) > > > sys.path.append(PROJECT_PATH) > > > os.environ['DJANGO_SETTINGS_MODULE'] = PROJECT_SETTING > > > > from looker import settings > > > > $ environ.py > > > Traceback (most recent call last): > > > File "./environ.py", line 11, in ? > > > from looker import settings > > > ImportError: No module named looker > > > --------------------------------------------<% > > > > Plus, is it possible that we could have something like "python > > > manage.py run environ.py" where django's 'manage.py' will take care of > > > this stuff and execute django dependent standalone application? I > > > could contribute the code but need some advices here. > > > > thanks, > > > Alex --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---