<?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>A Non-Programmer Approach to Django</title>
	<atom:link href="http://www.djangoapp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.djangoapp.com</link>
	<description>Dirty ways to get Around with Django Python Web Framework</description>
	<lastBuildDate>Sun, 31 Jul 2011 07:55:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Django Installation on Mac OS X Lion</title>
		<link>http://www.djangoapp.com/blog/2011/07/25/django-installation-on-mac-os-x-lion/</link>
		<comments>http://www.djangoapp.com/blog/2011/07/25/django-installation-on-mac-os-x-lion/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 17:49:19 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[mac os x 10.7]]></category>
		<category><![CDATA[mac os x lion]]></category>
		<category><![CDATA[mysql-python]]></category>
		<category><![CDATA[pil]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=97</guid>
		<description><![CDATA[Like many of Apple fanboys out there even I decided to upgrade Mac OS X Snow Leopard (10.6) to Mac OS X Lion (10.7) as soon as it was made available on App Store. Upgrading from App Store was pretty &#8230; <a href="http://www.djangoapp.com/blog/2011/07/25/django-installation-on-mac-os-x-lion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Like many of Apple fanboys out there even I decided to upgrade Mac OS X Snow Leopard (10.6) to Mac OS X Lion (10.7) as soon as it was made available on App Store. Upgrading from App Store was pretty smooth and was surprised it did not break any apps (May be that&#8217;s because it&#8217;s just an incremental upgrade with some fancy features) except my Django projects failing to validate because of the default python version change (from 2.6.x to 2.7.1) and can be easily fixed. However I decided to go for fresh install of OS X Lion to test how fresh install (wipe out disk after backup and install ) works with OS X Lion.</p>
<p>Once done with fresh installation of Mac OS X Lion, immediate task was setting up my development environment which includes MySQL server, phpMyAdmin and Django.</p>
<p>Steps I followed to get Django development environment back are as below</p>
<ol>
<li>Install Xcode via Mac OS X App Store ( Might be required when you compile and install from source)</li>
<li><a title="Installation of MySQL server on Mac OS X Lion" href="http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/">Install MySQL Server</a></li>
<li><a title="Installing phpMyAdmin on Mac OS X Lion" href="http://www.djangoapp.com/blog/2011/07/24/installing-phpmyadmin-on-mac-os-x-lion/">Install phpMyAdmin</a></li>
<li>By default jpeg, freetype, littlecms image library support is missing, you need to install at least jpeg support so ImageField in your django project supports jpeg formats.</li>
<ol>
<li>Install JPEG libraries</li>
<ol>
<li>Download JPEG library source <strong>curl -O http://www.ijg.org/files/jpegsrc.v8c.tar.gz</strong></li>
<li>Extract <strong>tar -xvzf jpegsrc.v8c.tar.gz</strong></li>
<li>Switch to jpeg directory <strong>cd jpeg-8c</strong></li>
<li>Run <strong>./confgure</strong></li>
<li>Run <strong>make</strong></li>
<li>Run <strong>sudo make install</strong></li>
</ol>
<li>Install Freetype libraries</li>
<ol>
<li>Download Freetype library source <strong>curl -O http://ftp.igh.cnrs.fr/pub/nongnu/freetype/freetype-2.4.5.tar.gz</strong></li>
<li>Extract <strong>tar -xvzf freetype-2.4.5.tar.gz</strong></li>
<li>Switch to freetype directory <strong>cd freetype-2.4.5</strong></li>
<li>Run <strong>./configure</strong></li>
<li>Run <strong>make</strong></li>
<li>Run <strong>sudo make install</strong></li>
</ol>
</ol>
<li>Install Django using <strong>sudo</strong> <strong>easy_install django</strong></li>
<li>Install Python Image Library (PIL) using <strong>sudo easy_install PIL</strong></li>
<li>Install mysql-python driver using <strong>sudo easy_install MySQL-python </strong>(Make sure you got mysql in your PATH, otherwise this will fail with mysql_config not found error)<strong><br />
</strong></li>
</ol>
<p>That&#8217;s all you need to go ahead and start creating Django projects. However I prefer using <a href="http://pypi.python.org/pypi/virtualenv">virtualenv</a> for all my Python projects. If you take this route, you can use <strong>pip install &lt;package_name&gt;</strong> to install necessary packages for example pip install django, pip install MySQL-python, pip install PIL to install Django, MySQL Python driver and Python Image Library.</p>
<p><strong>Update 1</strong> (25/07/2011): If you get error &#8220;django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/xxx/xxx/pyprojects/xxx/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib<br />
Referenced from: /Users/xxx/xxx/pyprojects/xxx/lib/python2.7/site-packages/_mysql.so<br />
Reason: image not found&#8221;, when you validate your project or try to use MySQL-python,</p>
<p>Type <strong>export DYLD_LIBRARY_PATH=&#8221;$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/&#8221; </strong>in your terminal and see if problem persists. You can add it to your .profile file to make this persistent so you don&#8217;t need to run it every time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2011/07/25/django-installation-on-mac-os-x-lion/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Installing phpMyAdmin on Mac OS X Lion</title>
		<link>http://www.djangoapp.com/blog/2011/07/24/installing-phpmyadmin-on-mac-os-x-lion/</link>
		<comments>http://www.djangoapp.com/blog/2011/07/24/installing-phpmyadmin-on-mac-os-x-lion/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 14:25:33 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mac os x 10.7]]></category>
		<category><![CDATA[mac os x lion]]></category>
		<category><![CDATA[mysql server]]></category>
		<category><![CDATA[phpmyadmin]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=79</guid>
		<description><![CDATA[This article is part of Django Installation on Mac OS X Lion Mac OS X by default ships with Apache web server which we will use to install (configure) phpMyAdmin to manage MySQL server installed previously on Mac OS X &#8230; <a href="http://www.djangoapp.com/blog/2011/07/24/installing-phpmyadmin-on-mac-os-x-lion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This article is part of <a title="Django Installation on Mac OS X Lion" href="http://www.djangoapp.com/blog/2011/07/25/django-installation-on-mac-os-x-lion/">Django Installation on Mac OS X Lion</a></p>
<p>Mac OS X by default ships with Apache web server which we will use to install (configure) phpMyAdmin to manage <a title="Installation of MySQL server on Mac OS X Lion" href="http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/">MySQL server installed</a> previously on Mac OS X 10.7 (aka Lion). At the end of this step-by-step tutorial, you should be able to access phpMyAdmin by opening http://localhost/phpMyAdmin in your preferred browser.</p>
<p>In this tutorial we will be using Terminal to move files around and edit/create files using command line.</p>
<h2><strong>Installing phpMyAdmin</strong></h2>
<ol>
<li>Start Apache if it&#8217;s not already running (You can check by running command &#8220;ps -ef | grep httpd&#8221; in terminal)</li>
<ol>
<li> Open System Preferences and Click Sharing
<p><div id="attachment_82" class="wp-caption alignnone" style="width: 310px"><a href="http://www.djangoapp.com/wp-content/uploads/2011/07/mac-os-x-web-sharing-apache.png"><img class="size-medium wp-image-82" title="Mac OS X Web Sharing Apache" src="http://www.djangoapp.com/wp-content/uploads/2011/07/mac-os-x-web-sharing-apache-300x247.png" alt="Start Apache Mac OS X" width="300" height="247" /></a><p class="wp-caption-text">Start Apache Mac OS X</p></div></li>
<li>Check Web Sharing Checkbox which should start web server (Apache) on your Mac</li>
<li>Open http://localhost in browser and you should see default page (on mine it just says &#8220;It Works&#8221; in H1 Tag)
<p><div id="attachment_83" class="wp-caption alignnone" style="width: 310px"><a href="http://www.djangoapp.com/wp-content/uploads/2011/07/mac-os-x-apache-homepage.png"><img class="size-medium wp-image-83" title="Mac OS X Apache Homepage" src="http://www.djangoapp.com/wp-content/uploads/2011/07/mac-os-x-apache-homepage-300x203.png" alt="Mac OS X Web sharing Homepage" width="300" height="203" /></a><p class="wp-caption-text">Mac OS X Apache Homepage</p></div></li>
</ol>
<li>By default, PHP module is not activated. Uncomment the line &#8221;<em>LoadModule php5_module libexec/apache2/libphp5.so</em>&#8221; in file &#8220;<em>/private/etc/apache2/httpd.conf</em>&#8221; to enable PHP on Mac OS X Apache web server. Default PHP version is PHP 5.3 (PHP 5.3.6 to be precise)</li>
<li>Download phpMyAdmin (Latest version at the time of writing this is 3.4.3.1) from <a title="phpMyAdmin download" href="http://www.phpmyadmin.net/home_page/downloads.php" target="_blank">phpMyAdmin Site</a>. Download page has quite a few options in terms of language and compresssion formats, so download the most relevant language pack and compression format you are comfortable with. (I downloaded phpMyAdmin-3.4.3.1-english.zip, please note your version may be different )</li>
<li>Open Terminal and Extract downloaded package to /usr/local/ by running command  &#8220;<strong><em>sudo unzip phpMyAdmin-3.4.3.1-english.zip -d /usr/local/</em></strong>&#8220;</li>
<li>Rename phpMyAdmin-3.4.3.1-english to phpMyAdmin by using command &#8220;<strong>sudo mv /usr/local/<em>phpMyAdmin-3.4.3.1-english /usr/local/<em>phpMyAdmin</em></em></strong><em><em>&#8221; in Terminal</em></em></li>
<li>Switch to phpMyAdmin directory using &#8220;<strong>cd /usr/local/phpMyAdmin</strong>&#8221; to create phpMyAdmin config file</li>
<li>By default config.inc.php file does not exist but phpMyAdmin ships with sample config which we can use. Copy config.sample.inc.php to config.inc.php using &#8220;<strong>sudo cp config.sample.inc.php config.inc.php</strong>&#8220;</li>
<li>Edit config.inc.php using your favorite editor (I prefer vi) and change <em><em>$cfg['Servers'][$i]['host'] = &#8216;localhost&#8217;; to $cfg['Servers'][$i]['host'] = &#8217;127.0.0.1&#8242;;<br />
</em></em><strong>*</strong>Well it sounds stupid because localhost and 127.0.0.1 are same in networking world but phpMyAdmin won&#8217;t let you (At least me) log in without this change and keeps throwing error &#8220;<strong>#2002 Cannot log in to the MySQL server</strong>&#8221;<br />
<strong>**</strong>If your MySQL is running on a different host/port, you can change them in this file<br />
<strong>***</strong>You can also use setup wizard offered by phpMyAdmin to configure phpMyAdmin further<br />
<strong>****</strong>You can also add random blowfish secret to config.inc.php to encrypt your session cookies.</li>
<li>Configure Apache to enable /phpMyAdmin</li>
<ol>
<li>Create phpMyAdmin apache config file with below text in bold in /etc/apach2/other/ directory using your favorite editor  &#8220;<strong>sudo vi /etc/apache2/other/phpMyAdmin.conf</strong>&#8220;<strong>Alias /phpMyAdmin /usr/local/phpMyAdmin</strong><br />
<strong>&lt;Directory /usr/local/phpMyAdmin&gt;</strong><br />
<strong>    Options Indexes</strong><br />
<strong>    Order allow,deny</strong><br />
<strong>    Allow from all</strong><br />
<strong>&lt;/Directory&gt;</strong></li>
</ol>
<li>Restart Apache by typing command sudo apachectl restart in terminal</li>
<li>Open http://localhost/phpMyAdmin in your browser and you should see phpMyAdmin Login Page
<p><div id="attachment_86" class="wp-caption alignnone" style="width: 310px"><a href="http://www.djangoapp.com/wp-content/uploads/2011/07/mac-os-x-phpmyadmin-login-screen.png"><img class="size-medium wp-image-86" title="Mac OS X phpMyAdmin Login Screen" src="http://www.djangoapp.com/wp-content/uploads/2011/07/mac-os-x-phpmyadmin-login-screen-300x249.png" alt="Mac OS X phpMyAdmin Login Screen" width="300" height="249" /></a><p class="wp-caption-text">Mac OS X phpMyAdmin Login Screen</p></div></li>
</ol>
<p>*Note Default phpMyAdmin does not allow you to login with empty passwords, you can change this behaviour but it is highly recommended to have password for mysql server accounts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2011/07/24/installing-phpmyadmin-on-mac-os-x-lion/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Installation of MySQL server on Mac OS X Lion</title>
		<link>http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/</link>
		<comments>http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/#comments</comments>
		<pubDate>Sun, 24 Jul 2011 09:22:08 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[mac os x 10.7]]></category>
		<category><![CDATA[mac os x lion]]></category>
		<category><![CDATA[mysql server]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=73</guid>
		<description><![CDATA[This article is part of Django Installation on Mac OS X Lion At the time of writing this post, MySQL Server on MySQL site doesn&#8217;t have installer package for OS X 10.7 (aka Lion) but 10.6 Package works just fine &#8230; <a href="http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>This article is part of <a title="Django Installation on Mac OS X Lion" href="http://www.djangoapp.com/blog/2011/07/25/django-installation-on-mac-os-x-lion/">Django Installation on Mac OS X Lion</a></em></p>
<p>At the time of writing this post, MySQL Server on MySQL site doesn&#8217;t have installer package for OS X 10.7 (aka Lion) but 10.6 Package works just fine for 10.7 as well. This may change soon and we may see package for OS X 10.7 as well or may be rename current package to 10.6 &amp; above.</p>
<p><strong>Installing MySQL community server:</strong></p>
<ol>
<li>Download the latest  64-Bit DMG Archive (Apple Disk Image) from MySQL Site (http://dev.mysql.com/downloads/mysql/). Current latest version is 5.5.14 which I&#8217;ll be using to install on my machine.</li>
<li>Mount the Disk Image (I mean open/double-click the DMG file) and install MySQL server by double-clicking the PKG file (in my case mysql-5.5.14-osx10.6-x86_64.pkg) and follow onscreen instructions. ( It will ask for Master password, as it installs MySQL server in /usr/local )</li>
<li>Add /usr/local/mysql/bin to your path by editing .profile file. (Optionally you can create alias to mysql and mysqladmin as mentioned in README File)</li>
<li>You can start MySQL server by running &#8220;/usr/local/mysql/bin/mysqld_safe &amp;&#8221; from terminal but Disk image you downloaded also consists of Startup Package &amp; Preferences Pane which allows you to start/stop MySQL server from System Preferences and even Automatically Start MySQL Server at Startup.</li>
</ol>
<p>*Please note /usr/local/mysql is only symlink to /usr/local/mysql-5.5.14-osx10.6-x86_64 which means when you upgrade to new version symlink will be changed to point to new version but won&#8217;t be deleting the older version. However you need to copy your data directory to new location to make sure your existing databases are intact post upgrade.</p>
<p><strong>Installing MySQL Startup Scripts &amp; Preferences Pane (OPTIONAL)</strong></p>
<ol>
<li>Double Click MySQLStartupItem.pkg and Follow on screen instructions (You will be asked for Master Password)</li>
<li>Double Click MySQL.prefPane which will add MySQL to OS X System Preferences and it should like something like below
<p><div id="attachment_74" class="wp-caption alignnone" style="width: 413px"><a href="http://www.djangoapp.com/wp-content/uploads/2011/07/mysql-mac-os-x-lion-preferences.png"><img class="size-full wp-image-74" title="MySQL Mac OS X Preferences" src="http://www.djangoapp.com/wp-content/uploads/2011/07/mysql-mac-os-x-lion-preferences.png" alt="MySQL Mac OS X Lion Preferences" width="403" height="199" /></a><p class="wp-caption-text">MySQL Mac OS X Lion Preferences</p></div></li>
<li>Check Automatically Start MySQL Server on Startup to start MySQL server at boot time.</li>
</ol>
<p>In next section we will discuss installing phpMyAdmin which will provide us web interface to perform basic MySQL administration tasks on Mac OS X Lion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2011/07/24/installation-of-mysql-server-on-mac-os-x-lion/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Practical Django Projects Book Review</title>
		<link>http://www.djangoapp.com/blog/2008/12/24/practical-django-projects-book-review/</link>
		<comments>http://www.djangoapp.com/blog/2008/12/24/practical-django-projects-book-review/#comments</comments>
		<pubDate>Thu, 25 Dec 2008 02:21:11 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[django apps]]></category>
		<category><![CDATA[Django book]]></category>
		<category><![CDATA[django ebook]]></category>
		<category><![CDATA[Django projects]]></category>
		<category><![CDATA[django reusable apps]]></category>
		<category><![CDATA[Practical Django Projects]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=68</guid>
		<description><![CDATA[I&#8217;ve started working on Python &#38; Django sometime around March 2008 and from then on started following Django IRC and Django blogs of which b-list by James Bennett is most useful/helpful till date. Also I use django-registration django resuable app &#8230; <a href="http://www.djangoapp.com/blog/2008/12/24/practical-django-projects-book-review/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">I&#8217;ve started working on Python &amp; Django sometime around March 2008 and from then on started following Django IRC and Django blogs of which <a title="James Bennett Blog" href="http://b-list.org">b-list</a> by James Bennett is most useful/helpful till date. Also I use <em><strong>django-registration</strong></em> django resuable app by James Bennett in all of my projects (even today) and hence I decided to order  the book Practical Django Projects by James Bennett in July and I was expecting to learn something new which is not in my arsenal.</p>
<p style="text-align: justify;"><span id="more-68"></span></p>
<p style="text-align: justify;">From March to July, I&#8217;ve read/worked a bit on Python and Django and even deployed couple of Django projects in production  before I ordered the book but I was under the impression I&#8217;m voilating Python&#8217;s philosophy of &#8220;only one way to do it&#8221; ,mostly because I rarely used model managers which I found in almost all Django reusable apps I&#8217;ve used and that&#8217;s one  major thing which I want to learn from this book.</p>
<p style="text-align: justify;">Recieved Practical Django Projects book after couple of days and with all excitement I jumped straightaway into the book and after reading about 50-60 pages I was like this book is for real beginners (myself a beginner that time)  beacuse I learned nothing new from what I knew already but  I did not give up and continued to read. Done reading entire Blog application and I was partially happy that I learned a bit about <strong>Django Signals</strong> and how to  use them to handle <strong>django comments moderation</strong> (which is on feature list for one of my projects ) but apart from Django Signals, most of them can be found in Django e-book by JKM and AH and the only difference is they are demonstrated as a part of project here.</p>
<p style="text-align: justify;">Then jumped on to building social code sharing site example (like djangosnippets) and learned few things like modelsManager and using Custom SQL, it&#8217;s not that you can&#8217;t find them in docs or django e-book but here they are demonstrated using a realtime example.</p>
<p style="text-align: justify;">Rest of the book focus on Writing Reusable apps, coding style, documentating the apps, coding for flexibility, packaging django apps which I think are favorite topics of author. You can find presentations on youtube on similar topics and <a title="Django Reusable Apps" href="http://uk.youtube.com/watch?v=A-S0tqpPga4">one of them is here from Djangocon</a> <img src='http://www.djangoapp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: justify;">Overall, Practical Django Projects is a good book but not a great and must have book. Practical Django Projects is a  book for beginner but not the one you can start with, you still have to read Djangobook and documentation before you get on to this book. As it&#8217;s titled most of the Django features are demonstrated here using practical projects and James did an excellent job covering most of the features/functionality (like Models/Views/Forms/Admin/Comments/Signals/Sitemaps/Syndication/Templates/Urls). The real problem is once you read Djangobook and gone through documentation, most of the code in this book looks obvious and if you are comfortable with Django documentation which is excellent, then in my opinion you can ignore this book.</p>
<p style="text-align: justify;"><strong>Note:</strong> This book was released before Django 1.0, so most of the code in the examples will not work (mostly contrib.admin refactored, contrib.comments refactored) and if you are looking to buy now, I would say wait for next version/update.</p>
<p style="text-align: justify;">PS: I bought the companion Practical Django Projects ebook today (for 10USD) and went through it again just before posting this book.</p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2008/12/24/practical-django-projects-book-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WYSIWYG Editor for Django</title>
		<link>http://www.djangoapp.com/blog/2008/12/17/wysiwyg-editor-for-django/</link>
		<comments>http://www.djangoapp.com/blog/2008/12/17/wysiwyg-editor-for-django/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 15:29:28 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[wymeditor]]></category>
		<category><![CDATA[wysiwyg]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=59</guid>
		<description><![CDATA[Lately I&#8217;ve been working on CMS like application for a news portal and one of the major features include integrating WYSIWYG editor to enable journalists post news online with ease. With almost zero expertise in Javascript, I thought this will &#8230; <a href="http://www.djangoapp.com/blog/2008/12/17/wysiwyg-editor-for-django/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Lately I&#8217;ve been working on CMS like application for a news portal and one of the major features include integrating WYSIWYG editor to enable journalists post news online with ease. With almost zero expertise in Javascript, I thought this will be a difficult activity but it turned out to be very easy and took less than an hour to integrate once we shortlisted on which editor we will be using.</p>
<p style="text-align: justify;"><span id="more-59"></span></p>
<p>We have looked at TinyMCE, FCKeditor and WYMeditor and finally decided to go with WYMeditor for many reasons which can be debated and importantly it fulfills all the features we need at this point of time.  Integrating WYMeditor in django is easy, for now we have integrated this in admin ( django.contrib.admin )  and we are planning to roll this out for users too in future. Below steps had worked for me and I think it should work for everyone.</p>
<ul>
<li>Download <a title="Jquery download" href="http://jquery.com/">jQeury</a> and copy it to somewhere on to MEDIA_ROOT so it can be accessed from browser. for eg., media.example.com/templates/js/jquery.js</li>
<li>Download <a title="WYMeditor" href="http://www.wymeditor.org/download/">WYMeditor</a> and extract it to somewhere on MEDIA_ROOT, so all files under wymeditor directory can be accessed. for eg., media.example.com/templates/js/wymeditor/jquery.wymeditor.pack.js</li>
<li>Create another javascript file to initialize editor on fields you need as shown below.

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// File Name: editor.js</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#id_content&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">wymeditor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// assuming content is field name with TextField.</span>
        updateSelector<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;input:submit&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//without this line and next line, you will be able to see editor but content will not be passed through POST.</span>
        updateEvent<span style="color: #339933;">:</span>    <span style="color: #3366CC;">&quot;click&quot;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Add all jquery.js, jquery.wymeditor.js and editor.js javascript files to ModelAdmin for models which you need Editor using admin Media class as shown below

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> settings
media = settings.<span style="color: black;">MEDIA_URL</span>
<span style="color: #ff7700;font-weight:bold;">class</span> ArticleAdmin<span style="color: black;">&#40;</span>admin.<span style="color: black;">ModelAdmin</span><span style="color: black;">&#41;</span>:
    <span style="color: #808080; font-style: italic;">#Your JS file paths may vary</span>
    <span style="color: #ff7700;font-weight:bold;">class</span> Media:
        js = <span style="color: black;">&#40;</span>media+<span style="color: #483d8b;">'templates/js/jquery.js'</span>, media+<span style="color: #483d8b;">'templates/js/wymeditor/jquery.wymeditor.js'</span>, media+<span style="color: #483d8b;">'templates/js/editor.js'</span><span style="color: black;">&#41;</span></pre></div></div>

</li>
</ul>
<p style="text-align: justify;">That&#8217;s it, reload the admin page and you should see a WYMeditor.</p>
<p style="text-align: justify;">It worked straightaway on localhost where I&#8217;m using django.views.static.serve to serve static files but when I moved this to production I had few problems with editor loading from media subdomain throwing error in firebug ( WYMeditor: error while parsing language file and to avoid the same I manually loaded lang file as well. )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2008/12/17/wysiwyg-editor-for-django/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Django Timestamp without using auto_now and auto_now_add</title>
		<link>http://www.djangoapp.com/blog/2008/12/12/django-timestamp-without-using-auto_now-and-auto_now_add/</link>
		<comments>http://www.djangoapp.com/blog/2008/12/12/django-timestamp-without-using-auto_now-and-auto_now_add/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 20:16:42 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[auto_now]]></category>
		<category><![CDATA[auto_now_add]]></category>
		<category><![CDATA[DateTimeField]]></category>
		<category><![CDATA[Django]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=28</guid>
		<description><![CDATA[If you have ever used/worked on CMS/Blogging apps, you might have noticed created and last updated timestamp&#8217;s for each content item (article/entry) and as you would expect Django also provide two options for DateTimeField which will enable you to create &#8230; <a href="http://www.djangoapp.com/blog/2008/12/12/django-timestamp-without-using-auto_now-and-auto_now_add/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">If you have ever used/worked on CMS/Blogging apps, you might have noticed created and last updated timestamp&#8217;s for each content item (article/entry) and as you would expect Django also provide two options for DateTimeField which will enable you to create timestamps automatically. DateTimeField with option auto_now_add ( models.DateTimeField(auto_now_add=True) ) can be used for created timestamp while DateTimeField with option auto_now ( models.DateTimeField(auto_now=True) ) can be used for last updated timestamp. Only drawback of auto_now and auto_now_add is they disable editing timestamps from admin.</p>
<p><span id="more-28"></span></p>
<p style="text-align: justify;">Well I think auto_now and auto_now_add are often used in development but for some reason Django core developers want to get rid of that and most likely auto_now and auto_now_add will be removed in version 2.0 (As mentioned during Django Technical Design, Djangocon 2008, video embedded below).  May be they want to reduce core size by removing the code which can be implemented easily or improve the same with new TimeStampField (Hinted by James Bennett during the same discussion, though I agree with Russel Keith having it doesn&#8217;t hurt)  but still no clarity if auto_now and auto_now_add will be part of Django 2.0 or not and I think one should avoid using them.</p>
<p style="text-align: justify;">It&#8217;s easy to achieve the same by overriding save method as shown below using example model. ( Most of the code is self explanatory and focus should be on created and updated fields)</p>
<p style="text-align: justify;"><strong>Before</strong> (with auto_now and auto_now_add) :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> Article<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:
    title = models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">100</span><span style="color: black;">&#41;</span>
    slug = models.<span style="color: black;">SlugField</span><span style="color: black;">&#40;</span>blank=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
    content = models.<span style="color: black;">TextField</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    created = models.<span style="color: black;">DateTimeField</span><span style="color: black;">&#40;</span>auto_now_add=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
    updated = models.<span style="color: black;">DateTimeField</span><span style="color: black;">&#40;</span>auto_now=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__unicode__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">title</span></pre></td></tr></table></div>

<p style="text-align: justify;"><strong>After</strong>( Same functionality without auto_now and auto_now_add ):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
<span style="color: #ff7700;font-weight:bold;">class</span> Article<span style="color: black;">&#40;</span>models.<span style="color: black;">Model</span><span style="color: black;">&#41;</span>:
    title = models.<span style="color: black;">CharField</span><span style="color: black;">&#40;</span>max_length=<span style="color: #ff4500;">100</span><span style="color: black;">&#41;</span>
    slug = models.<span style="color: black;">SlugField</span><span style="color: black;">&#40;</span>blank=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span>
    content = models.<span style="color: black;">TextField</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    created = models.<span style="color: black;">DateTimeField</span><span style="color: black;">&#40;</span>editable=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
    updated = models.<span style="color: black;">DateTimeField</span><span style="color: black;">&#40;</span>editable=<span style="color: #008000;">False</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__unicode__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">title</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> save<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #66cc66;">**</span>kwargs<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">self</span>.<span style="color: #008000;">id</span>:
            <span style="color: #008000;">self</span>.<span style="color: black;">created</span> = <span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># Edit created timestamp only if it's new entry</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">updated</span> = <span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">super</span><span style="color: black;">&#40;</span>Article,<span style="color: #008000;">self</span><span style="color: black;">&#41;</span>.<span style="color: black;">save</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>You can make created and updated fields editable in admin by removing editable=False from DateTimeField and adding a bit of code in save method to modify created and update timestamps as per your wish instead of current timings. (Hint: for new entry check created and updated are None and for existing entry(while editing), check the updated and created values with existing values)</p>
<p>Below is the Djangocon 2008 presentation where auto_now and auto_now_add are discussed (34:00)</p>
<p>[There is a video that cannot be displayed in this feed. <a href="http://www.djangoapp.com/blog/2008/12/12/django-timestamp-without-using-auto_now-and-auto_now_add/">Visit the blog entry to see the video.]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2008/12/12/django-timestamp-without-using-auto_now-and-auto_now_add/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Django on windows</title>
		<link>http://www.djangoapp.com/blog/2008/11/18/installing-django-on-windows/</link>
		<comments>http://www.djangoapp.com/blog/2008/11/18/installing-django-on-windows/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 20:14:04 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Database driver]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Installation]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=15</guid>
		<description><![CDATA[Well if you have decided to install Django, by now you must be knowing Django is a Python based web framework and in today&#8217;s post I&#8217;ll run through Django installation process on Windows including dependencies (like installation of Python, database, &#8230; <a href="http://www.djangoapp.com/blog/2008/11/18/installing-django-on-windows/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Well if you have decided to install Django, by now you must be knowing Django is a Python based web framework and in today&#8217;s post I&#8217;ll run through Django installation process on Windows including dependencies (like installation of Python, database, database adapters and other important libraries that Django depends on). If you already have Python installed, then skip Python installation section.</p>
<p style="text-align: justify;">Installing Django/Python/Python modules is same in all versions of windows and hence below steps are valid for Windows XP and Windows Vista. Those who are using Windows Vista, just make sure you run all installations as Administrator ( Right click setup file and run as administrator )</p>
<p style="text-align: justify;">Let&#8217;s begin by installing Python (If you already have a working Python installation, skip this section)</p>
<p style="text-align: justify;"><span id="more-15"></span></p>
<p style="text-align: justify;"><strong>Python Installation: </strong></p>
<ol style="text-align: justify;">
<li>Download latest Python binary for Windows from http://python.org/download/. Make sure you are using right binary file for your processor and always get the latest release</li>
<li>Install Python by double clicking the setup file you have downloaded in above setup and follow onscreen instructions.(Use defaults if possible or make sure you don&#8217;t have spaces and special characters in your installation path)</li>
<li>Edit your path settings and add Python to same. To edit path settings, right click My Computer and select properties which will open other window. Click advanced tab and then Environment variables and select PATH and click edit and add python installation path and it&#8217;s scripts (In my case C:\Python26\Tools\Scripts;C:\Python26; ) and click ok to save and comeout of that properties window by clicking ok.</li>
<li>Launch command prompt and then type python, you should see message like below. (If you get command not found, then most likely path is wrongly setup)</li>
</ol>
<p style="padding-left: 60px; text-align: justify;">Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32<br />
Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br />
&gt;&gt;&gt;exit( )<br />
*NOTE: Version numbers and processor models may be different</p>
<p style="text-align: justify;">If you face any problem , make sure you have set PATH variable correctly.</p>
<p style="text-align: justify;">Once we have Python working fine, we will move to next step to setup Django.</p>
<p style="text-align: justify;"><strong>Django Installation:</strong></p>
<ol style="text-align: justify;">
<li>Download Django from <a title="Django download" href="http://www.djangoproject.com/download/">Django Site</a> . There are two versions available,  Latest official version (Recommened for production) which can be downloaded directly or development version through svn. You need SVN client ( Tortise SVN, Free SVN client for Windows) .</li>
<li>If you are going with official version, extract the package and copy only the django(leave the docs, tests and examples etc.,) directory to site-packages ( site-packages will be under your Python installation path ( &lt;python-installation path&gt;\Lib\site-packages\ )</li>
<li>Add django to Environmental variables ( Like you did for Python installation step 3), just edit path settings and add &lt;python-installation path&gt;\Lib\site-packages\django\bin;</li>
<li>That&#8217;s it we are almost done installing django, Launch command prompt and type <strong>django-admin.py </strong>command and it should throw output similar to <em>Type &#8216;django-admin.py help&#8217; for usage.</em></li>
<li>Launch Python interpreter and run the commands <strong>import django</strong> and <strong>django.get_version()</strong> and output should look like below</li>
</ol>
<p style="padding-left: 90px;">D:\PROFILES\chundis&gt;python<br />
Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32<br />
Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br />
&gt;&gt;&gt; import django<br />
&gt;&gt;&gt; django.get_version()<br />
&#8217;1.0.1 final&#8217;<br />
&gt;&gt;&gt; exit()<br />
D:\PROFILES\chundis&gt;</p>
<p style="text-align: justify;">If you have any problems with step 4 and 5 of Django installation , just make sure you have copied the correct django directory to site-packages.</p>
<p style="text-align: justify;">We are done with Django installation but we need to install dependancies before we can start writing Django Apps.</p>
<p style="text-align: justify;">We still need to install Database and database driver for Python, so that our Django apps can use Database. Also we need to install Python Imaging Library (PIL) for Django to validate images and without this module, you won&#8217;t be able to use ImageField()</p>
<p style="text-align: justify;"><strong>Database Installation:</strong></p>
<p style="text-align: justify;">If you don&#8217;t have any preference, then try mySQL or Postgres.  Postgres comes with pgAdmin by default (A GUI based app to manage database) and for mySQL, there are GUI tools like phpMyAdmin and SQLyogi. I prefer mySQL with <a title="SQLYog download" href="http://www.webyog.com/">SQLYog Community Edition<br />
</a></p>
<ol>
<li>mySQL for windows can be downloaded from  <a title="mySQL download" href="http://dev.mysql.com/downloads/">http://dev.mysql.com/downloads/</a> and Postgres for windows can be download from <a title="Postgres for Windows download" href="http://www.postgresql.org/download/windows">http://www.postgresql.org/download/windows</a></li>
<li>Both the databases has Windows installers, so installation is pretty much like any other Windows application. Just double click the installer and follow onscreen instructions. There will be a option to select run as service (so make sure you select that, so it will run automatically on windows startup)</li>
</ol>
<p style="text-align: justify;">Next we need to install Python driver(adapter/module) for Python to communicate with database,</p>
<p style="text-align: justify;"><strong>Database Driver installation</strong></p>
<p style="text-align: justify;">Depending on the choice of database you made during previous section (Database installation), you need to install Database driver for Python.</p>
<ol>
<li>If you are using mySQL then Python module for mySQL can be download here ( http://sourceforge.net/projects/mysql-python/ ) or if you decide to use Postgres, then  Python module for PostGre can be downloaded here ( http://www.pygresql.org/readme.html#home-sites-of-the-different-packages ). Make sure you download the latest driver for your Python version. (Most of the drivers are packaged different for different Python versions)</li>
<li>Install database driver by executing the binary. (VIsta users, use run as administrator)</li>
<li>To test the database and database driver
<ol>
<li>Create a database</li>
<li>Launch command prompt and create django project using django-admin.py startproject &lt;projectname&gt;</li>
<li>Change Database settings in settings.py under project directory above command created.</li>
<li>cd (Change Directory) to you project directory execute python manage.py validate and it should display <em>0 errors found</em></li>
</ol>
</li>
</ol>
<p style="text-align: justify;">And finally we need Imaging library to support images.</p>
<p style="text-align: justify;"><strong>Python Imaging Library installation</strong><br />
On windows this is a straight forward installation, though it troubles a lot on Unix flavor OS to get jpeg support.</p>
<ol>
<li>Download the windows executable from http://www.pythonware.com/products/pil/ and execute it to install PIL (Vista users, run as administrator)</li>
</ol>
<p style="text-align: justify;">
<p style="text-align: justify;">That&#8217;s it, your windows box is now Django ready and you can start writing Django apps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2008/11/18/installing-django-on-windows/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Why Django blog with WordPress ?</title>
		<link>http://www.djangoapp.com/blog/2008/11/15/why-django-blog-with-wordpress/</link>
		<comments>http://www.djangoapp.com/blog/2008/11/15/why-django-blog-with-wordpress/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 21:21:08 +0000</pubDate>
		<dc:creator>Srik</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[django blog]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.djangoapp.com/?p=3</guid>
		<description><![CDATA[Reading about Django related stuff on WordPress (PHP) powered blog might be disrespectful to simple yet powerful Python based framework like Django, which let’s you create a decent blog within couple of hours. But I don’t think this site will &#8230; <a href="http://www.djangoapp.com/blog/2008/11/15/why-django-blog-with-wordpress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Reading about Django related stuff on WordPress (PHP) powered blog might be disrespectful to simple yet powerful Python based framework like Django, which let’s you create a decent blog within couple of hours. But I don’t think this site will end up as just an another blog and if at all it end up as a blog due to laziness then I’ll sure replace this one with Django based blog which has all important wordpress features I&#8217;m looking for like comment moderation (IP and keyword filtering), SEO, WYSIWYG editor, Akismet integration, Tagging to name a few which are often ignored by many developers out there.</p>
<p style="text-align: justify;">I&#8217;m pretty sure all those features are on mind of some of the programmers and we will see an blog app soon  but if they delay longer then I may end up writing one to move this from wordpress to Django.  Anyways we will have a migration guide from WordPress to Django as another post in form of  my migration experiences when when I migrate. Till such time, I&#8217;ll use Django badge I wish this site were powered by Django on footer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.djangoapp.com/blog/2008/11/15/why-django-blog-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.470 seconds -->
<!-- Cached page served by WP-Cache -->

