Re: import django models without runing the server

2011-07-21 Thread Kevin Anthony
I found the best way to do this is python manage.py < script.py On Jul 21, 2011 8:00 PM, "Gelonida N" wrote: > On 07/18/2011 04:33 PM, bruno desthuilliers wrote: >> On Jul 18, 3:33 pm, Alexander Crössmann >> wrote: >>> Hi Malcom, >>> >>> I am

Re: import django models without runing the server

2011-07-21 Thread Gelonida N
On 07/18/2011 04:33 PM, bruno desthuilliers wrote: > On Jul 18, 3:33 pm, Alexander Crössmann > wrote: >> Hi Malcom, >> >> I am not sure the management commands are what I want > > Strange enough, it seems that everyone starts by saying this and ends > up writing

Re: import django models without runing the server

2011-07-21 Thread Andre Terra
Nevermind, I thought you were referring to the previously sys.path.append() method. Regards, AT On Thu, Jul 21, 2011 at 1:13 PM, Andre Terra wrote: > On Jul 21, 4:53 pm, Jonas Geiregat wrote: >> > >> > This is a good read on the subject , it presents

Re: import django models without runing the server

2011-07-21 Thread Andre Terra
> > On Jul 21, 4:53 pm, Jonas Geiregat wrote: > > > > This is a good read on the subject , it presents an elegant solution. > > > > http://superjared.com/entry/django-and-crontab-best-friends/ > > > With the problem that it will use the first module named "settings" in >

Re: import django models without runing the server

2011-07-21 Thread Javier Guerra Giraldez
On Thu, Jul 21, 2011 at 10:27 AM, bruno desthuilliers wrote: > I maintain, from experience, that custom commands are the simplest, > safest and most flexible solution. same here -- Javier -- You received this message because you are subscribed to the Google

Re: import django models without runing the server

2011-07-21 Thread bruno desthuilliers
On Jul 21, 4:53 pm, Jonas Geiregat wrote: > > This is a good read on the subject , it presents an elegant solution. > > http://superjared.com/entry/django-and-crontab-best-friends/ With the problem that it will use the first module named "settings" in sys.path, which may *or

Re: import django models without runing the server

2011-07-21 Thread bruno desthuilliers
On Jul 21, 4:45 pm, Valder Gallo wrote: > Alexander, > > Try use this > > #test.py > import os, sys > sys.path.append('../') This is relative to whatever the current working directory is whenever the script is called. Very bad idea, will obviously break one day or another.

Re: import django models without runing the server

2011-07-21 Thread Jonas Geiregat
> Alexander, > > Try use this > > #test.py > import os, sys > sys.path.append('../') > os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' > > myproject/test.py > This is a good read on the subject , it presents an elegant solution.

Re: import django models without runing the server

2011-07-21 Thread Valder Gallo
Alexander, Try use this #test.py import os, sys sys.path.append('../') os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings' myproject/test.py On 07/18/2011 09:34 AM, Alexander Crössmann wrote: Hi, I want to write a python script that works with django models without runing the

Re: import django models without runing the server

2011-07-21 Thread Malcolm Box
On 18 July 2011 15:41, Shawn Milochik wrote: > On Mon, Jul 18, 2011 at 10:33 AM, bruno desthuilliers > wrote: > > On Jul 18, 3:33 pm, Alexander Crössmann > > wrote: > >> Hi Malcom, > >> > >> I am not sure the

Re: import django models without runing the server

2011-07-18 Thread Shawn Milochik
On Mon, Jul 18, 2011 at 10:33 AM, bruno desthuilliers wrote: > On Jul 18, 3:33 pm, Alexander Crössmann > wrote: >> Hi Malcom, >> >> I am not sure the management commands are what I want > > Strange enough, it seems that everyone

Re: import django models without runing the server

2011-07-18 Thread bruno desthuilliers
On Jul 18, 3:33 pm, Alexander Crössmann wrote: > Hi Malcom, > > I am not sure the management commands are what I want Strange enough, it seems that everyone starts by saying this and ends up writing custom management commands ;) -- You received this message

Re: import django models without runing the server

2011-07-18 Thread Alexander Crössmann
Hi Malcom, I am not sure the management commands are what I want, but the setting of the DJANGO_SETTINGS_MODULE environment variable helped. I had experimented with these settings already, but wasn't successful until now. So, thanks for the help! Alex Am 18.07.2011 15:17, schrieb Malcolm

Re: import django models without runing the server

2011-07-18 Thread Malcolm Box
On 18 July 2011 13:34, Alexander Crössmann wrote: > Hi, > > I want to write a python script that works with django models without > runing the server. My OS ist Ubuntu 10.10. > > I'd suggest using Django management commands:

import django models without runing the server

2011-07-18 Thread Alexander Crössmann
Hi, I want to write a python script that works with django models without runing the server. My OS ist Ubuntu 10.10. My skipt looks as follows: import sys sys.path.append('/home/myname/python/django_projects/') sys.path.append('/home/myname/python/') import settings from