{"id":68,"date":"2009-12-23T10:38:24","date_gmt":"2009-12-23T14:38:24","guid":{"rendered":"http:\/\/dashdrum.com\/blog\/?p=68"},"modified":"2010-07-16T21:51:44","modified_gmt":"2010-07-17T01:51:44","slug":"django-and-dreamhost","status":"publish","type":"post","link":"https:\/\/dashdrum.com\/blog\/2009\/12\/django-and-dreamhost\/","title":{"rendered":"Django and Dreamhost"},"content":{"rendered":"<p>Last month, Dreamhost announced their new support for Django using Passenger WSGI.  (<a href=\"http:\/\/wiki.dreamhost.com\/Django\">Instructions are posted here<\/a>.)<\/p>\n<p>The process is pretty simple.  First, I setup a new subdomain for the app.  One can probably setup a Django app using a subfolder of an existing domain, but I haven&#8217;t explored that yet.  As instructed, I setup the subdomain with the Passenger option.<\/p>\n<p>Next, I added a database for the domain.  Nothing tricky or new here.<\/p>\n<p>The final step in their instructions was to download and run the setup script.  I was a little confused about where I should run it, as the instructions referred to the &#8220;directory for the application&#8221;.  After a little experimentation, I figured out that I should be in the root directory for the subdomain (created when the subdomain was created), which has the <code>\/public<\/code> directory in it.  The script asks a few questions and runs quickly.  At the end, I had a <code>settings.py<\/code> and <code>urls.py<\/code>, the database was initialized, and the admin app was ready to go.  If the programmer is starting a new application, this is a good place to start.<\/p>\n<p>However, I have already been working on my app on my laptop, and I wanted to copy it to the server.  Since I&#8217;m using <a href=\"https:\/\/panel.dreamhost.com\/index.cgi?tree=goodies.svn&#038;\">Subversion<\/a> to store my code, it was easy to use the <code>svn co<\/code> command to copy the files over &#8211; after I first moved the recently created <code>settings.py<\/code> to a safe location.<\/p>\n<p>I copied the database and media location entries from the new <code>settings.py<\/code> into the existing version with my application.  I typed in the URL and was ready to go.<\/p>\n<p>EXCEPT &#8230; I forgot about a problem I hit when installing another Django app on Dreamhost using the older FastCGI configuration.  It seems that I have to qualify a couple of the file names in <code>settings.py<\/code> and <code>urls.py<\/code> to help Django find them.  Specifically, the applications listed in <code>INSTALLED_APPLICATIONS<\/code> need to have the project name appended to the beginning.  The same for imported URL files.  Those two changes did the trick.<\/p>\n<p>UPDATE: To solve this path problem, I added this line to passenger_wsgi.py:<\/p>\n<pre>sys.path.append(os.path.join(os.getcwd(),'project')) - where 'project' is the project name<\/pre>\n<p>EXCEPT &#8230; my application uses Python constructs (in this case, decorators) that were added after version 2.3, which is the default on my Dreamhost server.  With my <a href=\"http:\/\/gallery.gentryart.us\/photologue\/photo\/\">earlier Django install,<\/a> I had installed Python 2.5 in my <code>\/bin<\/code> folder and was able to directly the server to use that version.  Even after following the instructions I found in a discussion attached to the wiki page, I was not able to get this to work.  The command I added to <code>pasenger_wsgi.py<\/code> was:<\/p>\n<pre>if sys.version < \"2.5\": os.execl(\"\/home\/gentryadmin\/bin\/python\", *sys.argv)<\/pre>\n<p>Instead of using the new version, I see a screen telling me I have hit an Internal Server Error.  I've yet to find a log file that has information on this error.<\/p>\n<p>I can change the decorator code to Python 2.3 friendly syntax, but this problem will get in the way when\/if I want to use other Python\/Django applications or modules.  Hopefully, I can get this fixed.<\/p>\n<p>Any ideas or thoughts? Please leave a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last month, Dreamhost announced their new support for Django using Passenger WSGI. (Instructions are posted here.) The process is pretty simple. First, I setup a new subdomain for the app. One can probably setup a Django app using a subfolder of an existing domain, but I haven&#8217;t explored that yet. As instructed, I setup the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/dashdrum.com\/blog\/2009\/12\/django-and-dreamhost\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Django and Dreamhost&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-68","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts\/68","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/comments?post=68"}],"version-history":[{"count":6,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts\/68\/revisions"}],"predecessor-version":[{"id":154,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/posts\/68\/revisions\/154"}],"wp:attachment":[{"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/media?parent=68"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/categories?post=68"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dashdrum.com\/blog\/wp-json\/wp\/v2\/tags?post=68"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}