<?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; django</title>
	<atom:link href="http://www.peebs.org/tag/django/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>
		<item>
		<title>A Bit of Django Admin Trickery</title>
		<link>http://www.peebs.org/2009/08/a-bit-of-django-admin-trickery/</link>
		<comments>http://www.peebs.org/2009/08/a-bit-of-django-admin-trickery/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 16:47:08 +0000</pubDate>
		<dc:creator>PEEBS</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[django]]></category>

		<guid isPermaLink="false">http://peebs.org/?p=108</guid>
		<description><![CDATA[OK, so I&#8217;ve been playing with the latest release of Django (1.1, well technically I&#8217;m using the latest SVN release) and am really enjoying the things they&#8217;ve added since 1.0.
One major irritant I spent most of the morning working through, however, was something I think needs to be attended to, or at least clarified in [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so I&#8217;ve been playing with the latest release of Django (1.1, well technically I&#8217;m using the latest SVN release) and am really enjoying the things they&#8217;ve added since 1.0.</p>
<p>One major irritant I spent most of the morning working through, however, was something I think needs to be attended to, or at least clarified in the documentation.  I&#8217;ve got a model &#8220;Client&#8221; that can have more than one address &#8220;Address&#8221;, defined as a ForeignKey relationship.  I want to allow editing of the addresses inline for convenience, but kept getting pushback from the GUI when I&#8217;d try to just add in a client without an address.</p>
<p>Turns out, the Django automatic admin interface detects the presence/absence of fields in the inline widget to decide whether or not to validate the input.  In other words, if you&#8217;re putting any value into any of your Address&#8217; fields, it will validate them.  Because I was using a &#8220;USStateField()&#8221; type on my model, it was always putting in a value for the state, hence it was always failing the validation b/c I wasn&#8217;t putting in other fields.</p>
<p>Man, very frustrating.  Replacing &#8220;USStateField()&#8221; with a &#8220;models.CharField(max_length=2)&#8221; did the trick but I don&#8217;t think it was clear at all what was happening.</p>
<p>Anyone who has solved this more elegantly, please get in touch.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peebs.org/2009/08/a-bit-of-django-admin-trickery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
