<?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>Codegrind &#187; Djangp</title>
	<atom:link href="http://jordanovski.com/tag/djangp/feed" rel="self" type="application/rss+xml" />
	<link>http://jordanovski.com</link>
	<description>Homepage of Dusko Jordanovski</description>
	<lastBuildDate>Fri, 18 Jun 2010 17:37:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Configuring Django to work with your OSX X (Leopard) apache</title>
		<link>http://jordanovski.com/configuring-django-to-work-with-your-mac-os-x-apache</link>
		<comments>http://jordanovski.com/configuring-django-to-work-with-your-mac-os-x-apache#comments</comments>
		<pubDate>Fri, 27 Feb 2009 01:15:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Djangp]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[mod_python]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://jordanovski.com/?p=68</guid>
		<description><![CDATA[I hope that I finally got it right, since I can see the admin interface and the media files are being served by the same development server as the site.  The machine is an Intel MacBook running OS X 10.5.6 and python 2.6.1  I suggest reading the official Django documentation on setting it [...]]]></description>
			<content:encoded><![CDATA[<p>I hope that I finally got it right, since I can see the admin interface and the media files are being served by the same development server as the site.  The machine is an Intel MacBook running OS X 10.5.6 and python 2.6.1  I suggest reading the official <a href="http://docs.djangoproject.com/en/dev/howto/deployment/modpython/">Django documentation</a> on setting it with up mod_python first. I hope that this article can fill in the gaps. Remember to change the paths and names to the ones that you use.</p>
<h3>Configure the virtual hosts</h3>
<p>In this case 'mysite' is the name of the virtual host and 'my_site' is the name of the project, and server root directory. The server root was in my /Users/discodancer/Dev/my_site directory</p>
<pre><code style="font-family:monaco, consolas, monospace">&lt;VirtualHost *:80&gt;
  ServerAdmin jordanovskid@gmail.com
  DocumentRoot "/Users/discodancer/Dev/my_site"
  ServerName mysite
  ServerAlias mysite
  ErrorLog "/private/var/log/apache2/my_site-error_log"
  CustomLog "/private/var/log/apache2/</code><code style="font-family:monaco, consolas, monospace">my_site</code><code style="font-family:monaco, consolas, monospace">-access_log" common

  &lt;Directory "/Users/discodancer/Dev/</code><code style="font-family:monaco, consolas, monospace">my_site</code><code style="font-family:monaco, consolas, monospace">"&gt;
    Options FollowSymLinks MultiViews Includes
    AllowOverride All
    Order allow,deny
    Allow from all
  &lt;/Directory&gt;
  &lt;Location "/"&gt;
    SetHandler mod_python
    SetEnv DJANGO_SETTINGS_MODULE </code><code style="font-family:monaco, consolas, monospace">my_site</code><code style="font-family:monaco, consolas, monospace">.settings
    PythonHandler django.core.handlers.modpython
    PythonPath sys.path+['/Users/discodancer/Dev/']
  &lt;/Location&gt;

  # Do not use python interpreter for /media
  &lt;Location "/media"&gt;
    SetHandler none
  &lt;/Location&gt;

  # Do not use python interpreter for images
  &lt;LocationMatch ".(jpg|gif|png)$"&gt;
    SetHandler None
  &lt;/LocationMatch&gt;
&lt;/VirtualHost&gt;</code></pre>
<p>Then, to allow serving of media files, you need to make a symlink from django's contrib/admin/media directory to your project. The apache user normally does not have privileges to the django installation, so you need to do this.</p>
<pre><code style="font-family:monaco, consolas, monospace">ln -s /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/
contrib/admin/media/Users/discodancer/Dev/my_site/media</code></pre>
<p>(the path is too long, try not to paste the line breaks in your terminal :)  Then make a file apache_settings.py in your project directory/server root and paste these lines in it:</p>
<pre><code style="font-family:monaco, consolas, monospace">import osos.environ['PYTHON_EGG_CACHE'] = '/Users/discodancer/Temp'</code></pre>
<p>The path in my case is writable by the webserver (anyone for that matter). Finally add these 2 lines in the apache httpd.conf file. They will tell apache to load the settings from the file you just created.</p>
<pre><code style="font-family:monaco, consolas, monospace">PythonInterpreter my_site
PythonImport /Users/discodancer/Dev/my_site/apache_settings.py my_site</code></pre>
<p>Restart the web server.  I suppose you already know, but the apache httpd.conf file can be found in /etc/apache2/httpd.conf and the virtual hosts file can be found in /etc/apache2/extra/httpd-vhosts.conf. This should work :) at least it did for me.  One more note: at the moment of writing there is no current MySQLdb module for python 2.6. I am using the one that works with python 2.5 and each time I import it it throws a warning that the sets module is deprecated. Just ignore this, it didn't cause any trouble to me. If someone can explain what it really means, i'd be grateful.</p>
]]></content:encoded>
			<wfw:commentRss>http://jordanovski.com/configuring-django-to-work-with-your-mac-os-x-apache/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
