<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Creating a Django cron job</title>
	<atom:link href="http://slowchop.com/2006/09/17/creating-a-django-cron-job/feed/" rel="self" type="application/rss+xml" />
	<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/</link>
	<description></description>
	<lastBuildDate>Sun, 07 Feb 2010 14:55:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Scot Hacker</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-1322</link>
		<dc:creator>Scot Hacker</dc:creator>
		<pubDate>Sun, 23 Aug 2009 23:02:20 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-1322</guid>
		<description>It can also be really helpful to manually set the python path in the script itself, rather than relying on it being set in the environment. All of my scripts that interact with Django start with something like:

#################### Set up Django environment
import sys,os

sys.path.append(&#039;/home/crest/sites/lib&#039;)
sys.path.append(&#039;/home/crest/sites/projects&#039;)

os.environ[&#039;DJANGO_SETTINGS_MODULE&#039;] =&#039;ourcrestmont.settings&#039;

from django.core.management import setup_environ
from ourcrestmont import settings
setup_environ(settings)</description>
		<content:encoded><![CDATA[<p>It can also be really helpful to manually set the python path in the script itself, rather than relying on it being set in the environment. All of my scripts that interact with Django start with something like:</p>
<p>#################### Set up Django environment<br />
import sys,os</p>
<p>sys.path.append(&#8217;/home/crest/sites/lib&#8217;)<br />
sys.path.append(&#8217;/home/crest/sites/projects&#8217;)</p>
<p>os.environ['DJANGO_SETTINGS_MODULE'] =&#8217;ourcrestmont.settings&#8217;</p>
<p>from django.core.management import setup_environ<br />
from ourcrestmont import settings<br />
setup_environ(settings)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-1307</link>
		<dc:creator>Jacob</dc:creator>
		<pubDate>Thu, 16 Apr 2009 18:19:43 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-1307</guid>
		<description>You can just go
echo  &#039;import urr.reviews.scripts.test&#039; &#124; python manage.py shell</description>
		<content:encoded><![CDATA[<p>You can just go<br />
echo  &#8216;import urr.reviews.scripts.test&#8217; | python manage.py shell</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Kibbel</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-1105</link>
		<dc:creator>Mike Kibbel</dc:creator>
		<pubDate>Sat, 17 Nov 2007 05:13:18 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-1105</guid>
		<description>To solve this problem in a robust way, I&#039;ve extended the method described by Jared Kuolt: http://superjared.com/entry/django-and-crontab-best-friends/.  My technique lets you set up the Django environment in your cron job using one line of code without having to type in any long incantations or paths.  Check it out and download my reusable script at http://blog.capstrat.com/articles/making-django-environmentally-friendly/</description>
		<content:encoded><![CDATA[<p>To solve this problem in a robust way, I&#8217;ve extended the method described by Jared Kuolt: <a href="http://superjared.com/entry/django-and-crontab-best-friends/" rel="nofollow">http://superjared.com/entry/django-and-crontab-best-friends/</a>.  My technique lets you set up the Django environment in your cron job using one line of code without having to type in any long incantations or paths.  Check it out and download my reusable script at <a href="http://blog.capstrat.com/articles/making-django-environmentally-friendly/" rel="nofollow">http://blog.capstrat.com/articles/making-django-environmentally-friendly/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gerald Kaszuba</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-1031</link>
		<dc:creator>Gerald Kaszuba</dc:creator>
		<pubDate>Tue, 29 May 2007 23:12:45 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-1031</guid>
		<description>&lt;blockquote&gt;Heh, fixed the problem almost immediately after asking for help. Isn’t that always the way?&lt;/blockquote&gt;

Yes, it&#039;s happened to me countless times!</description>
		<content:encoded><![CDATA[<blockquote><p>Heh, fixed the problem almost immediately after asking for help. Isn’t that always the way?</p></blockquote>
<p>Yes, it&#8217;s happened to me countless times!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arthur McLean</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-1030</link>
		<dc:creator>Arthur McLean</dc:creator>
		<pubDate>Tue, 29 May 2007 19:34:14 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-1030</guid>
		<description>Heh, fixed the problem almost immediately after asking for help. Isn&#039;t that always the way? I just added:
sys.path.append(&quot;../&quot;)
That way the import worked fine. Perhaps this will be helpful to someone.</description>
		<content:encoded><![CDATA[<p>Heh, fixed the problem almost immediately after asking for help. Isn&#8217;t that always the way? I just added:<br />
sys.path.append(&#8221;../&#8221;)<br />
That way the import worked fine. Perhaps this will be helpful to someone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arthur McLean</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-1029</link>
		<dc:creator>Arthur McLean</dc:creator>
		<pubDate>Tue, 29 May 2007 19:26:58 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-1029</guid>
		<description>I&#039;ve tried following the steps outlined here and am getting an error. If I set os.environ[&#039;DJANGO_SETTINGS_MODULE&#039;] = &#039;settings&#039;, I get the error:
ImportError: No module named mytestproject

I&#039;ve also tried with mytestproject.settings and get:
EnvironmentError: Could not import settings &#039;mytestproject.settings&#039; (Is it on sys.path? Does it have syntax errors?): No module named mytestproject.settings

I&#039;m curious if I&#039;m missing something obvious such as where the python script should go? I put my script in the same folder as settings.py. Is that correct?</description>
		<content:encoded><![CDATA[<p>I&#8217;ve tried following the steps outlined here and am getting an error. If I set os.environ['DJANGO_SETTINGS_MODULE'] = &#8217;settings&#8217;, I get the error:<br />
ImportError: No module named mytestproject</p>
<p>I&#8217;ve also tried with mytestproject.settings and get:<br />
EnvironmentError: Could not import settings &#8216;mytestproject.settings&#8217; (Is it on sys.path? Does it have syntax errors?): No module named mytestproject.settings</p>
<p>I&#8217;m curious if I&#8217;m missing something obvious such as where the python script should go? I put my script in the same folder as settings.py. Is that correct?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kestrel</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-22</link>
		<dc:creator>kestrel</dc:creator>
		<pubDate>Mon, 18 Sep 2006 08:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-22</guid>
		<description>If a module_name is not a &quot;top-level&quot; module you&#039;ll need to use the following hack:


&lt;blockquote&gt;
module = __import__(module_name, globals(), locals(), [&#039;&#039;])
getattr(module, function_name)()
&lt;/blockquote&gt;
</description>
		<content:encoded><![CDATA[<p>If a module_name is not a &#8220;top-level&#8221; module you&#8217;ll need to use the following hack:</p>
<blockquote><p>
module = __import__(module_name, globals(), locals(), [''])<br />
getattr(module, function_name)()
</p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: kestrel</title>
		<link>http://slowchop.com/2006/09/17/creating-a-django-cron-job/comment-page-1/#comment-21</link>
		<dc:creator>kestrel</dc:creator>
		<pubDate>Sun, 17 Sep 2006 21:45:23 +0000</pubDate>
		<guid isPermaLink="false">http://slowchop.com/2006/09/17/creating-a-django-cron-job/#comment-21</guid>
		<description>You might try this instead of those exec\&#039;s...

&lt;blockquote&gt;
module = __import__(module_name)
getattr(module, functio_name)()
&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>You might try this instead of those exec\&#8217;s&#8230;</p>
<blockquote><p>
module = __import__(module_name)<br />
getattr(module, functio_name)()
</p></blockquote>
]]></content:encoded>
	</item>
</channel>
</rss>
