<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PEEBS.ORG &#187; python</title>
	<atom:link href="http://www.peebs.org/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peebs.org</link>
	<description>The Online Home of John J. Peebles</description>
	<lastBuildDate>Sun, 25 Jul 2010 22:01:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nasty Config Issue for Django and SQLite 3</title>
		<link>http://www.peebs.org/2009/11/nasty-config-issue-for-django-and-sqlite-3/</link>
		<comments>http://www.peebs.org/2009/11/nasty-config-issue-for-django-and-sqlite-3/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 21:17:45 +0000</pubDate>
		<dc:creator>PEEBS</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://peebs.org/?p=151</guid>
		<description><![CDATA[Was getting the following errors (alternately, depending on permissions settings):

&#8220;Unable to Open Database File&#8221;
&#8220;Unable to Write to Database File&#8221;

Found a lot of SQLite users complaining about this, then finally got the tip from this page that I needed to set my permissions on the parent director to writeable by the Apache user too.  What a [...]]]></description>
			<content:encoded><![CDATA[<p>Was getting the following errors (alternately, depending on permissions settings):</p>
<ul>
<li>&#8220;Unable to Open Database File&#8221;</li>
<li>&#8220;Unable to Write to Database File&#8221;</li>
</ul>
<p>Found a lot of SQLite users complaining about this, then finally got the tip from <a href="http://code.djangoproject.com/wiki/NewbieMistakes">this page</a> that I needed to set my permissions on the parent director to writeable by the Apache user too.  What a pain.</p>
<p>Another note: One nice thing that alleviates some of the normal irritation when moving between dev environments and production is the following code I added into the settings.py file:</p>
<pre style="padding-left: 30px;">import os.path
PROJECT_DIR = os.path.dirname(__file__)
DATABASE_NAME = os.path.join(PROJECT_DIR, "database.db")</pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peebs.org/2009/11/nasty-config-issue-for-django-and-sqlite-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Access Your Django Models from External Python Scripts</title>
		<link>http://www.peebs.org/2009/10/how-to-access-your-django-models-from-external-python-scripts/</link>
		<comments>http://www.peebs.org/2009/10/how-to-access-your-django-models-from-external-python-scripts/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 13:41:56 +0000</pubDate>
		<dc:creator>PEEBS</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://peebs.org/?p=137</guid>
		<description><![CDATA[Spent a good portion of time on this over the weekend, and it turned out to be frustrating enough and the answers available incomplete enough for me to want to document this here briefly.
I wanted to be able to populate my Django models from an external script by simply calling MyObject.save() .  My particular case [...]]]></description>
			<content:encoded><![CDATA[<p>Spent a good portion of time on this over the weekend, and it turned out to be frustrating enough and the answers available incomplete enough for me to want to document this here briefly.</p>
<p>I wanted to be able to populate my Django models from an external script by simply calling MyObject.save() .  My particular case was scraping some information off of a website using BeautifulSoup then inserting it into my Django application, where it would show up and be editable from the admin section.  It turned out that I had a major problem with environment variables, so after a lot of reading and some trial and error, the following should work for you.</p>
<pre style="padding-left: 30px;">import os
import sys

sys.path.append('/path/to/the/directory/above/your/project')
os.environ['DJANGO_SETTINGS_MODULE'] = 'yourproject.settings'
from  yourproject.yourapp.models import YourModel</pre>
<p>To be a little more clear: f your project is in &#8220;/Users/username/myproject&#8221;, append &#8220;/Users/username&#8221; to your system path.  This clears up your environment so that when you set the location of your django settings file using the dot notation, it knows where to look.</p>
<p>As always, if you have any questions or comments or a better way to do this, let me know.  I&#8217;m using this on Snow Leopard with a trunk SVN checkout of Django.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peebs.org/2009/10/how-to-access-your-django-models-from-external-python-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
