On 8/6/06, Todd O'Bryan <[EMAIL PROTECTED]> wrote: > > On Aug 5, 2006, at 10:32 PM, Malcolm Tredinnick wrote: > > > On Sun, 2006-08-06 at 07:05 +0800, limodou wrote: > >> If I write my own scripts which will use models and deal with them, > >> but I also need to set PYTHONPATH and DJANGO_SETTING_MODULE evn > >> variables. I know manage.py can do this thing, and I think why cann't > >> I use it to run my scripts which need these env variables setting. So > >> If I can run my scripts just like: > >> > >> manage.py run myscripts.py > > > > Rather than adding another feature to manage.py, I moved the > > environment > > setup lines out into their own function (in r3527). Now, if you > > want to > > write a script that operates in the same environment as manage.py > > would > > set up, you call > > > > django.core.management.setup_environ() > > > > early on in your main method and it should work seamlessly. > > Ooooh. That's pretty. > > Thank you, Malcom!! > I'v tried the new setup_environ function, and the code is:
import settings from django.core.management import setup_environ setup_environ(settings) You can not leave the parameters of setup_environ blank. And you need import the settings manually. But I need to know which settings file is using. How can I just do like manage.py does: 1) receive from command line options --settings= 2) receive from system environment DJANGO_SETTING_MODULE 3) if there is a settings.py in current directory, using it. -- I like python! My Blog: http://www.donews.net/limodou My Django Site: http://www.djangocn.org NewEdit Maillist: http://groups.google.com/group/NewEdit --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---
