<?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>The Usware Blog - Django Web Development &#187; about</title>
	<atom:link href="http://uswaretech.com/blog/category/about/feed/" rel="self" type="application/rss+xml" />
	<link>http://uswaretech.com/blog</link>
	<description>Building Amazing Webapps</description>
	<lastBuildDate>Tue, 08 Jun 2010 14:59:46 +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>Moving home</title>
		<link>http://uswaretech.com/blog/2010/06/moving-home/</link>
		<comments>http://uswaretech.com/blog/2010/06/moving-home/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 14:59:46 +0000</pubDate>
		<dc:creator>shabda</dc:creator>
				<category><![CDATA[about]]></category>
		<category><![CDATA[meta]]></category>

		<guid isPermaLink="false">http://uswaretech.com/blog/?p=983</guid>
		<description><![CDATA[Tl;dr version: We are moving our site from Uswaretech.com to Agiliq.com. Please update your book marks and the like. Longer version: We have moved. Our new, cool, and amazing site is Agiliq.com. Built with Django, pixie dust and pink unicorns, its is sure to amaze you. Please update your bookmarks. Gory details: New url: http://agiliq.com/ [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p></p><p>Tl;dr version:</p>

<p>We are moving our site from Uswaretech.com to Agiliq.com. Please update your book marks and the like.</p>

<p>Longer version:</p>

<p>We have moved. Our new, cool, and amazing site is <a href="http://agiliq.com/">Agiliq.com</a>. Built with Django, pixie dust and pink unicorns, its is sure to amaze you. Please update your bookmarks.</p>

<p>Gory details:</p>

<ul>
<li>New url: <a href="http://agiliq.com/">http://agiliq.com/</a></li>
<li>New Blog: <a href="http://agiliq.com/blog/">http://agiliq.com/blog</a></li>
<li>Twitter: <a href="http://twitter.com/agiliqdotcom">http://twitter.com/agiliqdotcom</a></li>
<li>Github: <a href="http://github.com/agiliq">http://github.com/agiliq</a></li>
</ul>

<p>If you are client of ours, the Unfuddle and billing details would be changing soon. (You should also have received an email from us.)</p>

<ul>
<li>Unfuddle: <a href="http://agiliq.unfuddle.com/">http://agiliq.unfuddle.com/</a></li>
<li>Freshbooks: <a href="http://agiliq.freshbooks.com/">http://agiliq.freshbooks.com/</a></li>
</ul>

<p>Thanks for being with Usware/Agiliq, and we are excited to start a new pahse in our journey, and have you with us.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://uswaretech.com/blog/2010/06/moving-home/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WordPress and Django: best buddies</title>
		<link>http://uswaretech.com/blog/2010/01/wordpress-and-django-best-buddies/</link>
		<comments>http://uswaretech.com/blog/2010/01/wordpress-and-django-best-buddies/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 14:25:29 +0000</pubDate>
		<dc:creator>shabda</dc:creator>
				<category><![CDATA[about]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://uswaretech.com/blog/?p=902</guid>
		<description><![CDATA[Summary: How to integrate a non Django database system in your Django code, using WordPress as example. The completed code is available at github or you can see some screnshots Though there are quite a few good Django blog applications, our blog is based on WordPress. A number of plugin&#8217;s make moving to a Django [...]


Related posts:<ol><li><a href='http://uswaretech.com/blog/2010/01/doing-things-with-django-forms/' rel='bookmark' title='Permanent Link: Doing things with Django forms'>Doing things with Django forms</a></li>
<li><a href='http://uswaretech.com/blog/2010/01/django-models-tutorial/' rel='bookmark' title='Permanent Link: Doing things with Django models &#8211; aka &#8211; Django models tutorial'>Doing things with Django models &#8211; aka &#8211; Django models tutorial</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p></p><p>Summary:
How to integrate a non Django database system in your Django code, using WordPress
as example. <a href="http://github.com/uswaretech/django-wordpress">The completed code is available at github</a> or you can <a href="#screenshots_wp">see some screnshots</a></p>

<hr />

<p>Though there are quite a <a href="http://github.com/montylounge/django-mingus">few good</a> <a href="http://byteflow.su/">Django blog</a> applications, our blog is based on
<a href="http://wordpress.org/">WordPress</a>. A <a href="http://mitcho.com/code/yarpp/">number</a> <a href="http://diythemes.com/">of</a> <a href="http://www.backtype.com/">plugin&#8217;s</a>
make moving to a Django based app a bad decision
for us, and not in the spirit of &#8220;best tools for the job&#8221;.</p>

<p>We moved the other way, and decided to use <a href="http://github.com/uswaretech/django-wordpress">Django to admin the
WordPress database</a>. The completed code is available on <a href="http://github.com/uswaretech/django-wordpress">Github</a></p>

<p>It is not too hard, with the the builtin Django commands. Django provides the
<a href="http://www.djangobook.com/en/1.0/chapter16/"><code>inspectdb</code></a> command which allows you to build your models.py from an existing
non Django database.</p>

<p>Here we will see the steps followed for WordPress, but it would be about the same for all
systems.</p>

<h5>Take a back up of wordpress</h5>

<pre><code>mysqldump -u wordpress_user -p --database wordpress_database &gt; data.sql
</code></pre>

<h5>Create a new project, and set its settings to use the WordPress database.</h5>

<pre><code>    DATABASE_ENGINE = 'mysql'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
    DATABASE_NAME = ''             # Or path to database file if using sqlite3.
    DATABASE_USER = ''             # Not used with sqlite3.
    DATABASE_PASSWORD = ''         # Not used with sqlite3.
    DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
    DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
</code></pre>

<h5>Get the initial models.py</h5>

<pre><code>./manage.py inspectdb &gt; models.py
</code></pre>

<p>This will create all the database tables in a form Django can understand. Here is what this command creates for a
my WordPress installation with the YARPP plugin. <a href="http://gist.github.com/278962">http://gist.github.com/278962</a></p>

<h5>Create a new app and put this models.py there.</h5>

<p>With this done, you can treat the non Django part as a
standalone application. Since WordPress appends all its table with <code>wp_</code> prefix,
we name this applications <code>wp</code> to maintain table name compatibility with Django naming
conventions.</p>

<p>You will notice that all models have the <code>db_table</code> populated, so we can rename tables, without changes to the database.</p>

<h5>Differences between WordPress and Django style naming.</h5>

<p>At this point you will notice some differences in how Django names things (in a
best practice sort of way), and how WordPress does it.</p>

<p>a. Django table and model class name are (generally) singular. eg <code>class Post(models.Models)</code> leads to table <code>app_post</code>.
WordPress tables are (most of them) named plural eg <code>wp_posts</code>.</p>

<p>b. Django attributes are generally named without the table name part. Eg</p>

<pre><code>class Comment(models.Model):
    author_name = models.TextField()
    content = models.TextField()
</code></pre>

<p>WordPress is explicit here and includes the table prefix with attributes.</p>

<pre><code>mysql&gt; desc wp_comments;
+----------------------+---------------------+------+-----+---------------------+----------------+
| Field                | Type                | Null | Key | Default             | Extra          |
+----------------------+---------------------+------+-----+---------------------+----------------+
| comment_ID           | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment | 
| comment_post_ID      | bigint(20) unsigned | NO   | MUL | 0                   |                | 
| comment_author       | tinytext            | NO   |     | NULL                |                | 
| comment_author_email | varchar(100)        | NO   |     |                     |                | 

.....
</code></pre>

<p>I believe this is due to the way you would generally be using the code. In Django you would do
<code>comment.author</code> where being explicit doesn&#8217;t add any value, while in WordPress, you would use,
<code>select comment_author, post_title ... from wp_comment, wp_post ... where join</code>, where being explicit
is useful.</p>

<p>You can decouple the Django and database names by using the <code>db_table</code> and <code>db_column</code> attributes.
We choose to rename the Class names to match Django conventions while we let the column names remain the same.</p>

<h5>Add Admin and other Django niceties.</h5>

<p>WordPress doesn&#8217;t (seem to) have foreign key constraints setup correctly, and
uses  <code>bigint(20) unsigned</code> without foreign key constraints to refer to referred entities.
This means Django creates all ForeignKeys as IntegerFields.</p>

<p>Modify them to use ForeignKey instead. Also add <code>__unicode__</code>, to your classes.</p>

<p>Add an <code>admin.py</code> to register all your classes.</p>

<p>And you are done! Now you can access, and work with your WordPress data inside Django
and Django admin.</p>

<hr />

<p>There are a few more things which will allow a easier WordPress setup.</p>

<h5>Create template tags to show the latest posts and comments.</h5>

<pre><code>@register.inclusion_tag("wp/recent_posts.html")
def show_posts(num_comments):
    return {"posts": Post.objects.filter(post_type="post", post_status="publish").order_by("-post_date")[:num_comments]}
</code></pre>

<p>So you can see that there is nothing WordPress specific we need too do here.</p>

<h5>Create a better admin.</h5>

<pre><code>Add ModelAdmin to generally used models.
</code></pre>

<h5>Allows accessing attributes via the Django style names.</h5>

<p>If you override <code>__getattr__</code>, you can access
the attributes via other names. Eg in the current setup you need to do <code>comment.comment_content</code>, <code>comment.comment_author</code> etc,
while we would like to do <code>comment.content</code>  and <code>comment.author</code> as a shortcut.</p>

<pre><code>class WordPressModel(object):    
    def __getattr__(self, v):
        if v in self.__dict__:
            return self.__dict__[v]
        else:
            new_v = "%s_%s" % (self.__class__.__name__.lower(),  v)
            if new_v in self.__dict__:
                return self.__dict__[new_v]
            else:
                raise AttributeError
</code></pre>

<p>It is highly debatable whether this is a good idea <img src='http://uswaretech.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> , but it is too convenient right now not to test this method out.</p>

<p><a name="screenshots_wp" />
Here are some screenshots.</p>

<p><img alt="" src="http://uswaretech.com/dump/screenshots/screenshot_010.png" title="WordPress django admin" class="alignnone" width="600" /></p>

<p><img alt="" src="http://uswaretech.com/dump/screenshots/screenshot_011.png" title="WordPress django admin" class="alignnone" width="600" /></p>

<hr />

<p><a href="http://feeds.feedburner.com/uswarearticles">Do you subscribe to our feed</a>? We recently made a full text feed available, so if you are using the old feed, you should change it. <a href="http://feeds.feedburner.com/uswarearticles">Subscribe now</a>.</p>


<p>Related posts:<ol><li><a href='http://uswaretech.com/blog/2010/01/doing-things-with-django-forms/' rel='bookmark' title='Permanent Link: Doing things with Django forms'>Doing things with Django forms</a></li>
<li><a href='http://uswaretech.com/blog/2010/01/django-models-tutorial/' rel='bookmark' title='Permanent Link: Doing things with Django models &#8211; aka &#8211; Django models tutorial'>Doing things with Django models &#8211; aka &#8211; Django models tutorial</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://uswaretech.com/blog/2010/01/wordpress-and-django-best-buddies/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>What is Usware Technologies?</title>
		<link>http://uswaretech.com/blog/2008/08/what-is-usware-technologies/</link>
		<comments>http://uswaretech.com/blog/2008/08/what-is-usware-technologies/#comments</comments>
		<pubDate>Wed, 27 Aug 2008 07:18:28 +0000</pubDate>
		<dc:creator>shabda</dc:creator>
				<category><![CDATA[about]]></category>
		<category><![CDATA[meta]]></category>

		<guid isPermaLink="false">http://uswaretech.com/blog/?p=6</guid>
		<description><![CDATA[From the sales pitch, Usware Technologies is a Web Application Development Studio specialising in Django and Jquery. We build &#8220;Amazing Web Apps&#8221;. But why Usware? A lot of software is built as Themware. They give you specifications, you take the specification, you never talk to them till the software is built. Waterfall Model of software [...]


No related posts.]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://uswaretech.com/blog/wp-content/uploads/2008/09/usware-what1.jpg"><img src="http://uswaretech.com/blog/wp-content/uploads/2008/09/usware-what1.jpg" alt="" title="usware-what1" width="500" height="157" class="alignnone size-medium wp-image-20" /></a></p>

<p>From the sales pitch,</p>

<blockquote>
  <p>Usware Technologies is a Web Application Development Studio specialising in Django and Jquery. We build &#8220;Amazing Web Apps&#8221;.</p>
</blockquote>

<p>But why <strong>Us</strong>ware?</p>

<p>A lot of software is built as <strong>Them</strong>ware. <em>They</em> give you specifications, <em>you</em> take the specification, <em>you</em> never talk to them till the software is built. <a href="http://en.wikipedia.org/wiki/Waterfall_model">Waterfall Model</a> of software development suck.</p>

<p>Software development does not have to suck. There is a better way to develop software.</p>

<p>With rise of <a href="http://www.python.org/">Agile Languages</a>, and <a href="http://agilemanifesto.org/">Agile Methodology</a>, we can start to build Usware. They give you specifications, you read it, and <strong>US</strong> builds it. Iterative development FTW.</p>

<h2>Enough theory. Why Usware?</h2>

<p>Your customers do not know what they want. When they say &#8220;we will know it, when we see it&#8221; they are correct. Software Development is complex not because the technology is complex, it is complex because your client requirements are complex, because people are complex. Themware models of development may help you fight technical complexity, but how can they fight the human complexity, if you never talk to end users during development.</p>

<h2>Even more enough theory. How Usware?</h2>

<p>Iterative Development, FTW! As Usware we develop Usware (Imagine that!). We use a <a href="http://uswaretech.unfuddel.com/">Project Management tool</a>, which does not fight us. We have <em>at least</em> a weekly iteration. The end users get a chance to give feedback early in the development cycle.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://uswaretech.com/blog/2008/08/what-is-usware-technologies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
