<?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>Misty thoughts &#187; web development</title>
	<atom:link href="http://blog.kfirbreger.com/tag/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kfirbreger.com</link>
	<description></description>
	<lastBuildDate>Tue, 13 Jul 2010 07:44:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Django and static files</title>
		<link>http://blog.kfirbreger.com/2008/09/26/django-and-static-files/</link>
		<comments>http://blog.kfirbreger.com/2008/09/26/django-and-static-files/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 18:18:18 +0000</pubDate>
		<dc:creator>Kfir</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://blog.kfirbreger.com/?p=90</guid>
		<description><![CDATA[After a long break I have resumed my side project in django. Last night I came upon a problem. When testing a page outside django, the page was rendered correctly. When it was rendered through django the javascript files were not located. At this point I have to admit I was a bit fullish and [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>After a long break I have resumed my side project in django. Last night I came upon a problem. When testing a page outside django, the page was rendered correctly. When it was rendered through django the javascript files were not located.</p>
</div>
<div>
<p>At this point I have to admit I was a bit fullish and forgot to look at the web server's log to see if the files were correctly served. that was an hour and a half of trying to figure out why the javascript functions were not found. So after smartening up I found out that the javascript files were not found. It seemed that django kept looking for them in the wrong location. Using the example <a href="http://docs.djangoproject.com/en/dev/howto/static-files/?from=olddocs">here</a> I eventually got it all to working.</p>
</div>
<div>
<p>It comes down to this. in the settings.py file there is a reference to the media URL and to the file system path to the media directory. Adding the following code to the urls.py<br />
<code><br />
if settings.DEBUG:<br />
urlpatterns += patterns('',<br />
(r'^tripcalc/media/(?P<br />
.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),<br />
)<br />
</code><br />
Will make sure that while django is in debug mode, serving of the static files will be done via django. for production sites it is better to let a dedicated web server (such as Apache) serve these static files.<br />
And that took care of it. I can now continue with the development. And it also enabled me to call the CSS file, so style is also shown. hurray.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kfirbreger.com/2008/09/26/django-and-static-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
