<?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/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Slacy's Blog &#187; models</title>
	<atom:link href="http://slacy.com/blog/tag/models/feed/" rel="self" type="application/rss+xml" />
	<link>http://slacy.com/blog</link>
	<description>This site is solar powered!</description>
	<lastBuildDate>Tue, 07 Sep 2010 23:45:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How to split views.py into a directory (Django, Python)</title>
		<link>http://slacy.com/blog/2009/07/how-to-split-views-py-into-a-directory-django-python/</link>
		<comments>http://slacy.com/blog/2009/07/how-to-split-views-py-into-a-directory-django-python/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 23:35:04 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[views]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=864</guid>
		<description><![CDATA[So, I&#8217;ve been doing some Django programming on the side, and the thing that annoys me is that Django forces you to put nearly all your source code into 2 files:  models.py and views.py Being a reasonable person, I wanted &#8230; <a href="http://slacy.com/blog/2009/07/how-to-split-views-py-into-a-directory-django-python/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;ve been doing some Django programming on the side, and the thing that annoys me is that Django forces you to put nearly all your source code into 2 files:  models.py and views.py</p>
<p>Being a reasonable person, I wanted to have a separate file for each view in my system.  In other words, I want to create a views directory, with __init__.py inside, and my view files in there.  Not being a Python expert, I found this harder than expected.  Here&#8217;s what you need to do:</p>
<ol>
<li>Create a views directory.</li>
<li>Split views.py into one file per method in the new views directory.</li>
<li>Edit views/__init__.py and for each view, say &#8220;from myview import *&#8221;</li>
<li>Use your views as you previously did in urls.py</li>
</ol>
<p>I&#8217;ve heard some rumblings that you could create an __init__.py that did something like go through every file in the current directory and import everything there.  That seems a bit over the top, and I&#8217;m happy to manage the imports in __init__.py for now.</p>
<p>I believe a very similar technique should work for Models, but I haven&#8217;t tested it.</p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2009/07/how-to-split-views-py-into-a-directory-django-python/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
	</item>
	</channel>
</rss>
