<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss version="2.0"><channel><title>Shifting Bits by Patrick Altman: Entries tagged with "django"</title><link>http://paltman.com/</link><description>The latest entries tagged with "django"</description><language>en-us</language><lastBuildDate>Fri, 17 Apr 2009 10:20:42 -0500</lastBuildDate><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/PatrickAltmanDjango" type="application/rss+xml" /><item><title>Nashvegas Issues</title><link>http://paltman.com/2009/apr/17/nashvegas-issues/</link><description>
&lt;p&gt;&lt;a href="http://github.com/blog/411-github-issue-tracker"&gt;GitHub has added integrated issue tracking&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;&lt;embed src="http://blip.tv/play/AfqxMpXxcg" type="application/x-shockwave-flash" width="528" height="360" allowscriptaccess="always" allowfullscreen="true"&gt;&lt;/embed&gt; 
&lt;/p&gt;
&lt;p&gt;So, in an effort to sample this awesomeness, I have converted my TODO file to &lt;a href="http://github.com/paltman/nashvegas/issues"&gt;issues for Nashvegas&lt;/a&gt;.  Please vote on the ones you care about and enter new ones that would be helpful for you.
&lt;/p&gt;


</description><pubDate>Fri, 17 Apr 2009 10:20:42 -0500</pubDate><guid>http://paltman.com/2009/apr/17/nashvegas-issues/</guid></item><item><title>Django Compress: New CSS Filter</title><link>http://paltman.com/2009/mar/23/django-compress-new-css-filter/</link><description>
&lt;p&gt;I added a new filter today for &lt;a href="http://github.com/paltman/django-compress"&gt;django-compress&lt;/a&gt; that allows for arbitrary string find/replace during the compile process on your css groups.
&lt;/p&gt;
&lt;p&gt;I had a specific use case for the new filter: my css had a lot of root relative urls for background images.  I wanted to host my compiled media on a different host than where my images were being hosted from but this tied the two together.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Furthermore, I didn't want to hard code the absolute urls as I want to be able to test the full environment on my laptop, test environments and finally be able to deploy somewhere else in production.  I want the process of changing environments to be simple settings file change.
&lt;/p&gt;
&lt;p&gt;Therefore, my approach was to &lt;a href="http://github.com/paltman/django-compress/commit/5038b5b04252767a1ae8766423baca5a6c6a94a2"&gt;create a filter that at compile time execute a string find and replace&lt;/a&gt;.  It's super simple, but useful, at least to me.
&lt;/p&gt;
&lt;p&gt;I also found what I think were a couple of bugs when you had some groups with &lt;code&gt;external_urls&lt;/code&gt; defined.  When they were missing &lt;code&gt;source_filenames&lt;/code&gt; and &lt;code&gt;output_filenames&lt;/code&gt; definitions, exceptions were raised when running the management command to compile the source.  I put some simple checks in place to safe guard against these exceptions.
&lt;/p&gt;


</description><pubDate>Mon, 23 Mar 2009 09:25:04 -0500</pubDate><guid>http://paltman.com/2009/mar/23/django-compress-new-css-filter/</guid></item><item><title>Patch to Django Extensions</title><link>http://paltman.com/2009/mar/19/patch-to-django-extensions/</link><description>
&lt;p&gt;I am really loving the &lt;a href="http://github.com/paltman/django-extensions"&gt;django-extensions project&lt;/a&gt;, especially the 
   &lt;a href="http://github.com/paltman/django-extensions/blob/4d1dbb14fb85ee8863cbbef2ef214ffcfcd53758/django_extensions/management/commands/sync_media_s3.py"&gt;sync_media_s3 command&lt;/a&gt; to move my media to be hosted on &lt;a href="http://s3.amazonaws.com"&gt;Amazon S3&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;I find it increasingly useful when combined with &lt;a href="http://github.com/paltman/django-compress"&gt;django-compress&lt;/a&gt;.  However, I ran into a snag today where I wanted to only sync to s3 my compiled scripts from django-compress, instead of my entire &lt;code&gt;MEDIA_ROOT&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;Therefore, I added the [a patch to add a &lt;code&gt;--dir&lt;/code&gt; optional parameter to the command](http://github.com/paltman/django-extensions/commit/4d1dbb14fb85ee8863cbbef2ef214ffcfcd53758).
&lt;/p&gt;


</description><pubDate>Thu, 19 Mar 2009 16:11:38 -0500</pubDate><guid>http://paltman.com/2009/mar/19/patch-to-django-extensions/</guid></item><item><title>New Django Site: Brite Revolution</title><link>http://paltman.com/2009/mar/15/new-django-site-brite-revolution/</link><description>
&lt;p&gt;&lt;a href="http://twitter.com/joshkersey"&gt;Josh Kersey&lt;/a&gt; &lt;a href="http://twitter.com/joshkersey/status/1329701799"&gt;announced tonight&lt;/a&gt; a new site built by the folks at &lt;a href="http://www.cabedge.com/"&gt;Cabedge&lt;/a&gt; and it appears to be done in &lt;a href="http://www.djangoproject.com"&gt;Django&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;&lt;img src="http://s3.amazonaws.com/paltman.com/images/Brite.png" style="margin-top:5px;" align="left"&gt;I love seeing fresh ideas, especially concerning digital media.  I have long thought the music industry just doesn't get the last 5 to 10 years of technological innovation and public mood shift.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Now, I am not industry expert, but I don't think it takes a wizard to see that Apple has single handedly been disruptive in this area.  Couple that with the ability for individuals to produce very high quality recordings in their basement cheaply and then leverage social media and the Internet to distribute their music.  The game has changed.&lt;img src="http://s3.amazonaws.com/paltman.com/images/brite2.png" style="float:right"&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.briterevolution.com"&gt;Brite Revolution&lt;/a&gt; is the first thing I have seen that is formerly recognizing that and building a business model around it.  From their &lt;a href="http://www.briterevolution.com/about/"&gt;About&lt;/a&gt; page:  &lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;blockquote&gt;&lt;blockquote&gt;&lt;p&gt;Artists need to be able to make music again without going into debt or losing ownership of their music.
   Fans need more music from their favorite artists on a regular basis and feel like a part of an event again.
   Philanthropic organizations need more opportunities to connect directly with people to make a difference in the world.
&lt;/p&gt;
&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;&lt;p&gt;To top it all off, they are committing to supporting non-profit charities to the tune 10% of gross subscriptions.  I will certainly be subscribing to this.
&lt;/p&gt;


</description><pubDate>Sun, 15 Mar 2009 02:03:31 -0500</pubDate><guid>http://paltman.com/2009/mar/15/new-django-site-brite-revolution/</guid></item><item><title>My Django-Compress Tasks</title><link>http://paltman.com/2009/mar/10/my-django-compress-tasks/</link><description>
&lt;p&gt;I am thoroughly impressed by &lt;a href="http://github.com/paltman/django-compress"&gt;django-compress&lt;/a&gt; as mentioned in &lt;a href="http://paltman.com/2009/mar/09/scratching-django-compact-for-django-compress/"&gt;yesterday's post&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;There are number of things that I'll be looking to add over the next couple of days that hopefully will make it even more useful for more than just me.  I'll be committing these to my fork and submitting pull requests upstream to hopefully have them committing into the main repository.
&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;
     For output files, create the intermediary folders if they don't exist.
 &lt;/li&gt;

 &lt;li&gt;
     Add a gzip option flag to the command to create gzip versions of the output files.
 &lt;/li&gt;

 &lt;li&gt;
     Add a new css filter for replacing url() property contents with prefixes defined in configuration (allowing for the serving of content locally during development, and then off of CDN servers when deployed).
 &lt;/li&gt;

 &lt;li&gt;
     Add a new version strategy, that will default to a prefix folder using today's timestamp (YYYYMMDD).  Also allow for an optional parameter to the command line to override this default prefix.
 &lt;/li&gt;

 &lt;li&gt;
     Add another &amp;quot;extra_context&amp;quot; variable called ABSOLUTE_URL to enable an override of both the PREFIX variable I included yesterday as well as the default MEDIA_URL.  I need this so as to be able to put things like Google hosted libraries like jQuery, but also to have a quick and easy way to revert to hosting it myself in production.
 &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;My goal for these additions is to keep them isolated and non-obstrusive so that they exist if others want to use them but don't get in the way of anything or otherwise clutter up the code.
&lt;/p&gt;
&lt;p&gt;I'd love to hear any feedback about these or other related ideas.
&lt;/p&gt;


</description><pubDate>Tue, 10 Mar 2009 12:07:00 -0500</pubDate><guid>http://paltman.com/2009/mar/10/my-django-compress-tasks/</guid></item><item><title>Scratching Django-Compact for Django-Compress</title><link>http://paltman.com/2009/mar/09/scratching-django-compact-for-django-compress/</link><description>
&lt;p&gt;Last week I talked about a project I had started to build called, &lt;a href="http://github.com/paltman/django-compact"&gt;django-compact&lt;/a&gt;, whose goal it was to provide a build process for all the various CSS and Javascript files in a given project.
&lt;/p&gt;
&lt;p&gt;I was quickly notified in via &lt;a href="http://willarson.com/"&gt;Will&lt;/a&gt; &lt;a href="http://lethain.com/"&gt;Larson&lt;/a&gt; &lt;a href="http://twitter.com/Lethain/status/1290551667"&gt;on Twitter&lt;/a&gt; that I should checkout &lt;a href="http://code.google.com/p/django-compress/"&gt;django-compress&lt;/a&gt;.  I did.  To say that I was following the same approach would be an understatement.  Furthermore, this project was much further along than I was.  I spent the better part of this morning getting a subsection of my project wired up to use it and am well satisfied.
&lt;/p&gt;
&lt;p&gt;There was a small additional feature I wanted to add, so I &lt;a href="http://github.com/paltman/django-compress"&gt;forked the project and made the additions&lt;/a&gt;.  I feel like the changes are non-breaking and generally useful and therefore hope to get them pushed upstream.&lt;a href="http://www.flickr.com/photos/shanegorski/2189027815/"&gt;&lt;img src="http://farm3.static.flickr.com/2323/2189027815_9ffe8dfb4a_m.jpg" border="0" align="left"&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;The feature in question involves being able to have multiple MEDIA_URLs for different outputs.  I call them PREFIXes.  My approach was to patch the &lt;code&gt;media_url&lt;/code&gt; function in &lt;code&gt;compress.utils&lt;/code&gt; to accept defaulted argument called &lt;code&gt;prefix&lt;/code&gt;.  If &lt;code&gt;prefix&lt;/code&gt; exists in a non-empty state, then it concatenates itself with the &lt;code&gt;url&lt;/code&gt; argument, otherwise it concatenates with the &lt;code&gt;settings.MEDIA_URL&lt;/code&gt; setting.
&lt;/p&gt;
&lt;p&gt;Upstream in &lt;code&gt;render_common&lt;/code&gt; I look for a dictionary key called &lt;code&gt;prefix&lt;/code&gt; in the &lt;code&gt;extra_context&lt;/code&gt; optional dictionary.  I then pass this value, that i default to &lt;code&gt;NONE&lt;/code&gt;, to the &lt;code&gt;media_url&lt;/code&gt; function that I updated.
&lt;/p&gt;
&lt;p&gt;Finally, in the &lt;code&gt;settings.py&lt;/code&gt;, I can now add the parameter when I want to serve the media off of different url paths.  This is primarily useful when there ends up being more than a few connections to media elements (images, css, js) on a single page request.  Being that most browsers by default will only open up a few connections in parallel per hostname, we &lt;a href="http://www.peterkrantz.com/2008/concurrent-browser-connections-ie8/"&gt;can speed things up by adding additional hostnames&lt;/a&gt;,  &lt;a href="http://developer.yahoo.com/performance/rules.html#cdn"&gt;especially when these hostnames are part of a CDN&lt;/a&gt; (at the &lt;a href="http://developer.yahoo.com/performance/rules.html#dns_lookups"&gt;cost of additional DNS lookups&lt;/a&gt;).
&lt;/p&gt;

&lt;h3&gt;Patch&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;diff --git a/compress/templatetags/compressed.py b/compress/templatetags/compressed.py
index 0b236e3..f9c55f9 100644
--- a/compress/templatetags/compressed.py
+++ b/compress/templatetags/compressed.py
@@ -14,10 +14,11 @@ def render_common(template_name, obj, filename, version):
         filename = get_output_filename(filename, version)

     context = obj.get('extra_context', {})
+    prefix = context.get('prefix', None)
     if filename.startswith('http://'):
         context['url'] = filename
     else:
-        context['url'] = media_url(filename)
+        context['url'] = media_url(filename, prefix)

     return template.loader.render_to_string(template_name, context)

diff --git a/compress/utils.py b/compress/utils.py
index 6fd21c1..fba6075 100644
--- a/compress/utils.py
+++ b/compress/utils.py
@@ -60,7 +60,9 @@ def media_root(filename):
     &amp;quot;&amp;quot;&amp;quot;
     return os.path.join(django_settings.MEDIA_ROOT, filename)

-def media_url(url):
+def media_url(url, prefix=None):
+    if prefix:
+        return prefix + urlquote(url)
     return django_settings.MEDIA_URL + urlquote(url)

 def concat(filenames, separator=''):
&lt;/code&gt;&lt;/pre&gt;

</description><pubDate>Mon, 09 Mar 2009 17:25:58 -0500</pubDate><guid>http://paltman.com/2009/mar/09/scratching-django-compact-for-django-compress/</guid></item><item><title>Django-Compact Updates</title><link>http://paltman.com/2009/mar/06/django-compact-updates/</link><description>
&lt;p&gt;Getting back into the swing of things on &lt;a href="http://github.com/paltman/django-compact"&gt;django-compact&lt;/a&gt; today:
&lt;/p&gt;

&lt;h4&gt;Today's Commits&lt;/h4&gt;
&lt;ul&gt;
 &lt;li&gt;
     Got concatenation working for both js and css
 &lt;/li&gt;

 &lt;li&gt;
     Added minification support via &lt;a href="http://developer.yahoo.com/yui/compressor/"&gt;YUI Compressor&lt;/a&gt;
 &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This second item in the list leads me to a question about best practices when creating a re-distributable Django app.  Minification support is an optional flag passed at run time to build your css/js:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./manage.py compact --minify
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If specified, it will run the concatenated files through the YUI Compressor minifier.  Since this tool is java based, and not python :(, I decided to include the jar file in a lib folder under the application folder.
&lt;/p&gt;
&lt;p&gt;I then created a module called &lt;code&gt;yui.py&lt;/code&gt; and encapsulated the shell out via &lt;code&gt;Popen&lt;/code&gt; in a python class called &lt;code&gt;Compressor&lt;/code&gt;.  This does assume that the &lt;code&gt;java&lt;/code&gt; executable is in your path and is of a version greater than 1.4 (YUI Compressor requires at least 1.4).
&lt;/p&gt;
&lt;p&gt;The question I have is, is there a best practice of where and when to include binaries such as this?  I feel that this is pretty clean in that I construct the path to the jar dynamically at run time so i don't assume any particular install location.  I could do more up front checking for the existence of &lt;code&gt;java&lt;/code&gt; and the version number.
&lt;/p&gt;
&lt;p&gt;Any thoughts?
&lt;/p&gt;


</description><pubDate>Fri, 06 Mar 2009 16:30:50 -0500</pubDate><guid>http://paltman.com/2009/mar/06/django-compact-updates/</guid></item><item><title>Nashvegas: A Simple Django Migration Tool</title><link>http://paltman.com/2009/feb/24/nashvegas-a-simple-django-migration-tool/</link><description>

&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;Back in July &lt;a href="http://paltman.com/2008/jul/03/managing-database-changes-in-django/"&gt;I discussed how I built a tool&lt;/a&gt; 
   to help manage database changes across a team and through deployment for our Django based project.
&lt;/p&gt;
&lt;p&gt;And yes, I am aware of &lt;a href="http://code.djangoproject.com/wiki/SchemaEvolution"&gt;other approaches/projects tackling this same problem&lt;/a&gt;. None of them seemed to work how I wanted them to as they all seemed to focus on trying to keep you 
   from writing the raw sql yourself.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I am comfortable with writing SQL and for something that will 
   execute automatically against production databases, I prefer to have that control in knowing exactly
   what will get executed.  Yes, many of these tools have options to allow me to preview the generated
   SQL, but it still gave me the feeling of being boxed in.
&lt;/p&gt;
&lt;p&gt;For your reference, here are the ones I reviewed:
   &lt;div style="float:right"&gt;&lt;img src="http://s3.amazonaws.com/media.paltman.com/images/nashvegas.jpg" alt="NashVegas" style="margin:0; margin-right:25px;margin-left: 10px; margin-bottom: 10px; border: 2px solid black;"&gt;&lt;/div&gt;
&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;
     &lt;a href="http://south.aeracode.org/"&gt;South&lt;/a&gt;
 &lt;/li&gt;

 &lt;li&gt;
     &lt;a href="http://code.google.com/p/dmigrations/"&gt;dmigrations&lt;/a&gt;
 &lt;/li&gt;

 &lt;li&gt;
     &lt;a href="http://code.google.com/p/django-evolution/"&gt;django-evolution&lt;/a&gt;
 &lt;/li&gt;

 &lt;li&gt;
     &lt;a href="http://code.google.com/p/deseb/"&gt;deseb&lt;/a&gt;
 &lt;/li&gt;

 &lt;li&gt;
     &lt;a href="http://code.google.com/p/yadsel"&gt;yadsel&lt;/a&gt;
 &lt;/li&gt;

 &lt;li&gt;
     &lt;a href="http://code.google.com/p/schema-evolution/"&gt;schema-evolution&lt;/a&gt;
 &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So I abstracted out the script and it's assumptions about our environment to function as a management 
   command in a stand alone reusable app.
&lt;/p&gt;

&lt;h4&gt;My Approach&lt;/h4&gt;
&lt;p&gt;It's extremely simple and is based purely on executing SQL statements in order based on it's file 
   naming scheme.  Basically, you create a folder somewhere in your project -- I call mine &amp;quot;db&amp;quot;.  Within
   this folder you put the changes to the database into SQL scripts named using a convention that will 
   list them in order.  I use:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;YYYYMMDD-##.sql
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This allows members of the team to know at a glance when the script was created and gives some reasonable
   avoidance of name collisions.  There have been instances where we've had a name collision (I try to push
   in a commit that has 20090224-01.sql added in my commit index and it already exists in the remote branch, 
   so I just move the file to 20090224-02.sql, commit, pull and then push again).
&lt;/p&gt;
&lt;p&gt;To sync up your database with changes from the rest of the team you would just execute:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./manage.py upgradedb --execute
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you wanted to just see the output that will be executed you can run it without the --execute flag to 
   just print out the contents to standard output:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./manage.py upgradedb
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;By default, it looks for a folder with scripts in your current working directory called &amp;quot;db&amp;quot;.  If your
   scripts are located elsewhere, just use the --path parameter:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;./manage.py upgradedb --execute --path /path/to/db/folder
&lt;/code&gt;&lt;/pre&gt;
&lt;h4&gt;Where to Get It&lt;/h4&gt;
&lt;p&gt;I have &lt;a href="http://github.com/paltman/nashvegas/downloads"&gt;released v0.1&lt;/a&gt; of the app as it has the bare minimum now to be usable.  But there are handful of 
   other additions that I think will make it generally more useful.  I do welcome any and all feedback on 
   this project, but want to restate this isn't meant as a replacement or competition for the other migration 
   projects listed above.  I have reviewed all of them, and none fit how I preferred to work.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I also welcome any patches, so &lt;a href="http://paltman.github.com/nashvegas"&gt;head over to the project and fork it&lt;/a&gt;!
&lt;/p&gt;
&lt;p&gt;I figured since they really didn't fit my needs and/or what I wanted to do, then there might be others in the same boat and might find what I have done to be useful.
&lt;/p&gt;


</description><pubDate>Tue, 24 Feb 2009 10:17:41 -0500</pubDate><guid>http://paltman.com/2009/feb/24/nashvegas-a-simple-django-migration-tool/</guid></item><item><title>To FogBugz With Python</title><link>http://paltman.com/2009/jan/30/submit-error-reports-fogbugz-python/</link><description>
&lt;p&gt;A couple of weeks ago, I &lt;a href="http://paltman.com/2009/jan/09/wrapping-fogbugz-with-python/"&gt;announced the pyfogbugz project&lt;/a&gt; that will, when complete, serve as a python wrapper around the FogBugz API.  I have had very little time to spend on it recently so it has not progressed much at all.  However, one feature that I have added recently is the ability to use the simple BugzScout interface for submitting bug reports.
&lt;/p&gt;
&lt;p&gt;The one feature about this interface that solves an immediate problem for me is being able to deal with duplicate exception reports.  One of my major annoyances with picking up exception reports from an email inbox that FogBugz creates tickets from is that it can't deal with duplicates, so I end up spending a lot of time gardening tickets that are duplicates of each other.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;BugzScout will solve this problem by automatically appending to a ticket that has an identical title.  I find this extremely useful.
&lt;/p&gt;
&lt;p&gt;While the library is not comlete, the BugzScout part of it is usable.  To install and use:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;git clone git://github.com/paltman/pyfogbugz.git
cd pyfogbugz 
pylink pyfogbugz   ## See link [1] to Eric Florenzano's post
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now in your python script:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from pyfogbuz.scout import post_report
post_report('title of the report', 'body of the report -- what wil be appended to ticket if dupe title')
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You may be wondering, how does it know where to submit my tickets.  Good question!  See the README for a sample configuration file.  Put configuration options in a file at one of the following two places:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/etc/pyfogbugz.cfg
~/.pyfogbugz
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;A then correct the sample settings to match your own.
&lt;/p&gt;
&lt;p&gt;Next step for me will be to wire up this function call somewhere in the &lt;a href="http://djangoproject.com"&gt;Django&lt;/a&gt; stack to send exception reports using this script in addition to the email (or maybe I just setup a script to read the email inbox) and then turn off email reading from FogBugz.
&lt;/p&gt;
&lt;p&gt;[1] &lt;a href="http://www.eflorenzano.com/blog/post/first-two-django-screencasts/"&gt;Eric Florenzano's pylink&lt;/a&gt;
&lt;/p&gt;


</description><pubDate>Fri, 30 Jan 2009 16:28:07 -0500</pubDate><guid>http://paltman.com/2009/jan/30/submit-error-reports-fogbugz-python/</guid></item><item><title>Mobile Django Admin Patches</title><link>http://paltman.com/2009/jan/01/mobile-django-admin-patches/</link><description>
&lt;p&gt;In addition to adding a couple of minor, but useful (at least for me), patches to to the awesome &lt;a href="http://code.google.com/p/django-mobileadmin/"&gt;django-mobileadmin project&lt;/a&gt; by &lt;a href="http://jannisleidel.com"&gt;Jannis Leidel&lt;/a&gt;, I learned something new about how Python works.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;The first patch was simply removing an extra slash from a URL in a template.  No big deal:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;commit 599f172df85586742b5b1ef2bd5b7a24298a0839
Author: Patrick Altman &amp;lt;patrick@###.com&amp;gt;
Date:   Wed Dec 31 23:13:57 2008 -0600

    fixed bug where app links had an extra trailing slash

diff --git a/mobileadmin/templates/mobileadmin/mobile_safari/index.html b/mobileadmin/templates/mobileadmin/mobile_safar
index 046a39d..1d66f59 100644
--- a/mobileadmin/templates/mobileadmin/mobile_safari/index.html
+++ b/mobileadmin/templates/mobileadmin/mobile_safari/index.html
@@ -10,7 +10,7 @@
 {% if app_list %}
     &amp;lt;ul id=&amp;quot;applist&amp;quot; selected=&amp;quot;true&amp;quot;&amp;gt;
     {% for app in app_list %}
-    &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;{{ app.app_url }}/&amp;quot; id=&amp;quot;{{ app.name|slugify }}_app&amp;quot;&amp;gt;{% blocktrans with app.name as name %}{{ name }}{%
+    &amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;{{ app.app_url }}&amp;quot; id=&amp;quot;{{ app.name|slugify }}_app&amp;quot;&amp;gt;{% blocktrans with app.name as name %}{{ name }}{% 
     &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;truncate({'{{ app.name|slugify }}_app': 35});&amp;lt;/script&amp;gt;
     {% endfor %}
     &amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a href="http://www.flickr.com/photos/paltman/3155782336/" title="Django Mobile for ShiftingBits by Patrick Altman, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3224/3155782336_a66fa7b511.jpg" align="left"  width="310" height="450"  alt="Django Mobile for ShiftingBits" /&gt;&lt;/a&gt;The second patch took a bit more research to figure out what was going on.  The symptom I was witnessing was that the mobile interface looked fine in my iPhone until I tried to view a model's list of objects.  It kept showing me the default admin view (as you would expect to on the desktop) and it didn't jive with the (screenshots I saw on Flickr)[http://www.flickr.com/photos/jannis/sets/72157607145456697/] that Jannis had posted showing off the app.
&lt;/p&gt;
&lt;p&gt;After seeing some drastic differences between the output of a &lt;code&gt;dir&lt;/code&gt; command on the &lt;code&gt;admin_site&lt;/code&gt; variable and the contents of &lt;code&gt;admin_site.__dict__&lt;/code&gt;, it quickly became apparent that &lt;code&gt;__dict__&lt;/code&gt; on the object wasn't showing the whole picture and thus there was a bug in the &lt;code&gt;autoregister&lt;/code&gt; function.
&lt;/p&gt;
&lt;p&gt;I then found &lt;a href="http://www2.lib.uchicago.edu/keith/"&gt;Keith Waclena&lt;/a&gt;'s excellent &lt;a href="http://www2.lib.uchicago.edu/keith/courses/python/class/5/#attrref"&gt;course documentation describing the problem perfectly&lt;/a&gt;.  It turns out that &lt;code&gt;__dict__&lt;/code&gt; only reveals the members of the class or instance and NOT the inherited members, so one must recurse down through base classes to be complete.  So, I borrowed his recursive lookup function, and rewrote a couple lines to approach the lookup differently but accomplishing the same intent (at least I hope so -- it seems to work as intended for me):
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;commit 5945491fe1216239471d41e590425bfe384d3d99
Author: Patrick Altman &amp;lt;patrick@###.com&amp;gt;
Date:   Thu Jan 1 00:52:46 2009 -0600

    fixed bug in autoregister where attribute searching didn't search deep enough (didn't search base classes)

diff --git a/mobileadmin/__init__.py b/mobileadmin/__init__.py
index f8658ac..77e0de1 100644
--- a/mobileadmin/__init__.py
+++ b/mobileadmin/__init__.py
@@ -4,6 +4,21 @@ from django.core.exceptions import ImproperlyConfigured
 from mobileadmin import decorators, views
 from mobileadmin.conf import settings

+### From http://www2.lib.uchicago.edu/keith/courses/python/class/5/#attrref
+def classlookup(C, name):
+       if C.__dict__.has_key(name):
+               return (1, C.__dict__[name])
+       else:
+               for b in C.__bases__:
+                   success, value = classlookup(b, name)
+                   if success:
+                           return (1, value)
+                   else:
+                           pass
+               else:
+                   return (0, None)
+
+
 def autoregister():
     &amp;quot;&amp;quot;&amp;quot;
     Auto-register all ModelAdmin instances of the default AdminSite with the
@@ -14,11 +29,11 @@ def autoregister():

     for model, modeladmin in main_site._registry.iteritems():
         admin_class = modeladmin.__class__
-
-        for name, value in admin_class.__dict__.iteritems():
-            if name in settings.TEMPLATE_MAPPING:
+        for name in settings.TEMPLATE_MAPPING:
+            (found, value) = classlookup(admin_class, name)
+            if found:
                 setattr(admin_class, name, decorators.mobile_templates(value))
-
+                
         if admin_class == UserAdmin:
             setattr(admin_class, 'add_view', views.auth_add_view)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I have pushed in these changes to my fork of the git project and sent pull requests to Jannis.  Hopefully, he'll integrate them into his project soon, but in the meantime, &lt;a href="http://github.com/paltman/django-mobileadmin"&gt;my fork is available&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;Being that this occurred shortly after the stroke of midnight, it is officially the first thing that I have done in 2009!
&lt;/p&gt;
&lt;p&gt;Happy New Year!
&lt;/p&gt;


</description><pubDate>Thu, 01 Jan 2009 01:31:01 -0500</pubDate><guid>http://paltman.com/2009/jan/01/mobile-django-admin-patches/</guid></item><item><title>Shifting Bits: Twitter Integration Added</title><link>http://paltman.com/2008/nov/04/shifting-bits-twitter-integration-added/</link><description>
&lt;p&gt;I just added integration to Twitter so that when making a blog post active in &lt;a href="http://github.com/paltman/shiftingbits"&gt;Shifting Bits&lt;/a&gt; a post is sent to the Twitter account configured in the &lt;code&gt;settings.py&lt;/code&gt; file.
&lt;/p&gt;
&lt;p&gt;As part of the post to Twitter, the url for the post is passed through &lt;a href="http://urlzen.com/"&gt;urlzen&lt;/a&gt; to shorten the link so everything is nice an tidy.
&lt;/p&gt;
&lt;p&gt;This post will serve as it's first public test (so hopefully it works!).
&lt;/p&gt;


</description><pubDate>Tue, 04 Nov 2008 10:25:16 -0500</pubDate><guid>http://paltman.com/2008/nov/04/shifting-bits-twitter-integration-added/</guid></item><item><title>CivicSquared</title><link>http://paltman.com/2008/oct/30/civicsquared/</link><description>
&lt;p&gt;This is a call to action, folks.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Please &lt;a href="http://generalapp.newschallenge.org/SNC/ViewItem.aspx?pguid=4a4f8c6a-d2c2-4545-82db-c8ed4b415eba&amp;amp;itemguid=6d31da2d-94c3-4007-8044-706206900430"&gt;go vote for CivicSquared&lt;/a&gt; to get funding to bring such a great idea to reality.
&lt;/p&gt;
&lt;p&gt;The Knight News Challenge is a contest where $5 million worth of projects will be funded.  The projects are those with a focus &amp;quot;on neighborhood and community-focused projects, services, and programs&amp;quot;.
&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://generalapp.newschallenge.org/SNC/ViewItem.aspx?pguid=4a4f8c6a-d2c2-4545-82db-c8ed4b415eba&amp;amp;itemguid=6d31da2d-94c3-4007-8044-706206900430"&gt;CivicSquared&lt;/a&gt; project goal is essentially opening up government:
&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;&amp;quot;The same prudence, which, in private life, would forbid our paying our money for unexplained projects, forbids it in the disposition of public moneys.&amp;quot; -- Thomas Jefferson
&lt;/p&gt;
&lt;p&gt;CivicSquared is social software that helps communities obtain and discuss information about local legislation, tax allocation, and elected officials' voting records. It will be released as an open source Django application.
&lt;/p&gt;
&lt;p&gt;Most citizens do not know how their local taxes are spent. While it is true that citizens can voice opinions at the public meetings where these decisions are made, there are enormous barriers to effective participation. Some of these barriers include advance access to agendas, to information about issues, and to past deliberations on those issues. Even when agendas are posted in advance, there are often questions, and the impact of legislation on a community is often unclear without a public dialogue. One cannot assume that local media will offer multiple perspectives and unbiased views due to a lack of diversity in media ownership at the local level. Something needs to be done to make the process more inclusive.
&lt;/p&gt;
&lt;p&gt;CivicSquared seeks to address these problems via services far beyond basic access to public meeting records. Our goal is to provide communities the simple, powerful tools to be aware of public meetings, comment on upcoming legislation, track that legislation and who voted for it, and see how their tax dollars are being spent.
&lt;/p&gt;
&lt;p&gt;With CivicSquared, we aim to address all the principles of Open Government and will work with the OpenGov community to follow, implement, and produce standard formats for storing and sharing this data in a structured and semantic way. 
&lt;/p&gt;
&lt;/blockquote&gt;&lt;p&gt;This is beyond really cool.  It's vitally important for our democracy.  So with voting on everyone's mind (at least here in the US), please &lt;a href="http://generalapp.newschallenge.org/SNC/ViewItem.aspx?pguid=4a4f8c6a-d2c2-4545-82db-c8ed4b415eba&amp;amp;itemguid=6d31da2d-94c3-4007-8044-706206900430"&gt;go vote for this awesome project&lt;/a&gt;.
&lt;/p&gt;


</description><pubDate>Thu, 30 Oct 2008 17:09:12 -0500</pubDate><guid>http://paltman.com/2008/oct/30/civicsquared/</guid></item><item><title>JSONField for Django Models</title><link>http://paltman.com/2008/oct/21/jsonfield-for-django-models/</link><description>
&lt;p&gt;I was needing to store semi-structured data on a model for a project I am working on, but didn't want to parse strings or create a foreign key to a key/value type table.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;The use of JSON came to mind via the simplejson library.  I thought leveraging Python's dict and list data structures would provide ample flexibility will minimizing any parsing of text (at least directly by me).  Before I set out to write a JSON field type, I thought I'd give Google a try and &lt;a href="http://www.djangosnippets.org/snippets/377/"&gt;sure enough someone (deadwisdom) had beat me to it&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;This snippet is really cool in that now I can declare fields of type JSONField() and simple interact with them as python data types however, they get saved to the database as simplejson encoded strings and rehydrated back from strings into their original data structure, leaving you without having to think about how the data will be stored.
&lt;/p&gt;


</description><pubDate>Tue, 21 Oct 2008 13:28:33 -0500</pubDate><guid>http://paltman.com/2008/oct/21/jsonfield-for-django-models/</guid></item><item><title>Shifting Bits: My Django Blog is Live</title><link>http://paltman.com/2008/oct/19/shifting-bits-my-django-blog-is-live/</link><description>
&lt;p&gt;Just a short announcement to say that I am finally free of Wordpress and mod_php on my server.  This site is Django-powered!
&lt;/p&gt;
&lt;p&gt;Still lots more that I want to do with it, but my basic requirements are complete (comments, comment moderation, xmlrpc interface for MarsEdit compatibility, rss feeds, and tagging).
&lt;/p&gt;


</description><pubDate>Sun, 19 Oct 2008 21:46:57 -0500</pubDate><guid>http://paltman.com/2008/oct/19/shifting-bits-my-django-blog-is-live/</guid></item><item><title>The Django Toolbar: Updated</title><link>http://paltman.com/2008/oct/16/the-django-toolbar-updated/</link><description>
&lt;p&gt;So &lt;a href="http://paltman.com/2008/10/13/the-django-debug-un-toolbar/"&gt;after some late night code slinging to scratch a wild itch of an idea&lt;/a&gt;, I rethought my approach in how I forked the code for the &lt;a href="http://github.com/robhudson/django-debug-toolbar"&gt;Django Debug Toolbar&lt;/a&gt; project.  Partly this was prompted by some folks that took some time to leave a few comments on the previous post announcing the release -- many thanks!
&lt;/p&gt;
&lt;p&gt;Anyway, I just committed changes to a &lt;a href="http://github.com/paltman/django-debug-toolbar/tree/master"&gt;new fork of the Django Toolbar project&lt;/a&gt; that I hope is considering merge worthy by Rob Hudson to get back into the project and my fork can live a short but useful life until my pull request is incorporated.
&lt;/p&gt;
&lt;p&gt;The basics of this change is that you can control whether or not server side logging occurs as well as whether or not the toolbar is displayed via some configuration settings that are documented in the &lt;a href="http://github.com/paltman/django-debug-toolbar/tree/master/README.rst"&gt;README.rst&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;Check it out and let me know what you think.  I'd like to build some dashboard type tools for browsing the server side logged data.  But beyond that I think it is probably ready to start using.
&lt;/p&gt;


</description><pubDate>Thu, 16 Oct 2008 03:12:17 -0500</pubDate><guid>http://paltman.com/2008/oct/16/the-django-toolbar-updated/</guid></item><item><title>The Django Debug Un-Toolbar</title><link>http://paltman.com/2008/oct/13/the-django-debug-un-toolbar/</link><description>
&lt;p&gt;When I caught wind of the &lt;a href="http://github.com/robhudson/django-debug-toolbar"&gt;Django Debug Toolbar&lt;/a&gt; a couple weeks ago, I was really excited to put it to use.  However, when i wired it up, I discovered that it wasn't going to play nicely with &lt;a href="http://mootools.net/"&gt;MooTools&lt;/a&gt; since it is based on &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Not being a javascript expert, I am assuming there is some global namespace collisions in how the two libraries use shortcut functions like the dollar sign selectors (e.g. $('some-dom-element')).
&lt;/p&gt;
&lt;p&gt;Anyway, the more I thought about it, I figured it probably best to not manipulate the DOM at all.  In some discussion with others, it was determined a very useful adaptation to the project would be to serialize off all the data collected in the middleware on the server and set a cookie to a special path so that it could be retrieved via something like a bookmarklet.
&lt;/p&gt;
&lt;p&gt;So that's what I did.  I forked the &lt;a href="http://github.com/robhudson/django-debug-toolbar"&gt;Django Debug Toolbar&lt;/a&gt; project and renamed it to &lt;a href="http://github.com/paltman/django-debug-untoolbar"&gt;Django Debug Un-Toolbar&lt;/a&gt;, real original, I know.  While I don't expect it to be perfect yet (I spent about 2 hours this evening making sweeping and hurried changes to the code base), it does work as intended.
&lt;/p&gt;
&lt;p&gt;There are a number of things I want to add/change before I dare think about using in production.  Yes, I think it would be useful to have in production, and triggered to turn on in a number of different ways -- either through changing a settings parameter to passing it a special query string parameter, or working for certain users.
&lt;/p&gt;
&lt;p&gt;By having the debug &amp;quot;toolbar&amp;quot; work in this manner it will be possible to collect all this good debug information from customers who's screens are unavailable to see when things inevitable go wrong and you need to troubleshoot things quickly.
&lt;/p&gt;

&lt;h3&gt;Update&lt;/h3&gt;
&lt;p&gt;I am closing the Un-Toolbar fork in favor of &lt;a href="http://paltman.com/2008/10/15/the-django-toolbar-updated/"&gt;the other fork that i created that is more upstream compatible&lt;/a&gt;.  Hopefully that fork is only temporary as well as I'd hope to get it worthy of merging back to Rob's repository.
&lt;/p&gt;


</description><pubDate>Mon, 13 Oct 2008 05:53:53 -0500</pubDate><guid>http://paltman.com/2008/oct/13/the-django-debug-un-toolbar/</guid></item><item><title>Shifting Bits Makes Progress</title><link>http://paltman.com/2008/oct/13/shifting-bits-makes-progress/</link><description>
&lt;p&gt;I have done a little more hacking on &lt;a href="http://github.com/paltman/shiftingbits/"&gt;Shifting Bits&lt;/a&gt; this weekend and have launched a beta version of it:
&lt;/p&gt;
&lt;p&gt;&lt;a href="http://beta.paltman.com"&gt;http://beta.paltman.com&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;In order to keep crawlers and indexers out of it and not leaving it up to trusting that they obey a good robots.txt instruction set, I have put some simple low-tech authentication on it (HTTP Basic).
&lt;/p&gt;
&lt;p&gt;The username and password for this beta site is paltman/test.
&lt;/p&gt;
&lt;p&gt;I'd love to hear any feedback about what's there.
&lt;/p&gt;
&lt;p&gt;This was mainly a test to get my environment where it needed to be to host the blog as well as to exercise my Wordpress import tool somewhere other than my laptop.
&lt;/p&gt;


</description><pubDate>Mon, 13 Oct 2008 05:43:23 -0500</pubDate><guid>http://paltman.com/2008/oct/13/shifting-bits-makes-progress/</guid></item><item><title>DjangoCon Sessions: Video</title><link>http://paltman.com/2008/sep/16/djangocon-sessions-video/</link><description>
&lt;p&gt;The &lt;a href="http://www.youtube.com/view_play_list?p=D415FAF806EC47A1"&gt;DjangoCon sessions are now up on YouTube&lt;/a&gt;.
&lt;/p&gt;


</description><pubDate>Tue, 16 Sep 2008 20:34:54 -0500</pubDate><guid>http://paltman.com/2008/sep/16/djangocon-sessions-video/</guid></item><item><title>Shifting Bits: Another Django Blog Engine</title><link>http://paltman.com/2008/sep/08/shifting-bits-another-django-blog-engine/</link><description>
&lt;p&gt;Tonight I released/open-sourced &lt;a href="http://github.com/paltman/shiftingbits"&gt;ShiftingBits&lt;/a&gt;.  This blog is still on &lt;a href="http://wordpress.org"&gt;WordPress&lt;/a&gt;, but I believe I am close to having the all the features I need/require to make the migration possible.
&lt;/p&gt;
&lt;p&gt;I pretty much stole a bunch from &lt;a href="http://github.com/brosner/oebfare"&gt;Brian Rosner's oebfare code base&lt;/a&gt; so if any of it looks familiar, that's where I copied a lot of this from.  Thanks, Brian!
&lt;/p&gt;
&lt;p&gt;If you are wanting to move from a WordPress blog to your own Django-based site, you might be able to save some time with this blog engine.  This is exactly the path I am taking.
&lt;/p&gt;
&lt;p&gt;I am using:
   &lt;ul&gt;
   &lt;li&gt;&lt;a href="http://mootools.net/"&gt;mootools 1.2&lt;/a&gt; -- JavaScript library awesomeness&lt;/li&gt;
   &lt;li&gt;&lt;a href="http://code.google.com/p/blueprintcss/"&gt;blueprint&lt;/a&gt; -- CSS framework&lt;/li&gt;
   &lt;li&gt;&lt;a href="http://wmd-editor.com/"&gt;wmd&lt;/a&gt; -- Live markdown preview for comments&lt;/li&gt;
   &lt;li&gt;&lt;a href="http://code.google.com/p/google-code-prettify/"&gt;prettify&lt;/a&gt; -- Really cool syntax highlighter&lt;/li&gt;
   &lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;Feature Summary:
   &lt;ul&gt;
   &lt;li&gt;Basic blog post mode driven using generic date based views with redirects  so that the WordPress url date format (numbered month versus the prettier and django default of short month name) get mapped properly so that none of your links break.&lt;/li&gt;
   &lt;li&gt;WordPress to Django Migration Script&lt;/li&gt;
   &lt;li&gt;Tagging via &lt;a href="http://code.google.com/p/django-tagging/"&gt;django-tagging&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;Comments via the new &lt;a href="http://docs.djangoproject.com/en/dev/ref/contrib/comments/"&gt;django.contrib.comments&lt;/a&gt; and using &lt;a href="http://wmd-editor.com/"&gt;the live markdown preview editor, wmd&lt;/a&gt;.&lt;/li&gt;
   &lt;li&gt;Full RSS feeds (both latest feeds and by tag)&lt;/li&gt;
   &lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;Left to To:
   &lt;ul&gt;
   &lt;li&gt;Implement an XML-RPC interface that Mars Edit can communicate with.&lt;/li&gt;
   &lt;li&gt;Add Google Analytics&lt;/li&gt;
   &lt;li&gt;Clean up CSS so that the templates look better.&lt;/li&gt;
   &lt;li&gt;Handle Trackbacks/Pingbacks&lt;/li&gt;
   &lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;This is the code that I am planning to use shortly here at &lt;a href="http://paltman.com"&gt;paltman.com&lt;/a&gt;, including the css/templates.  I would love to hear feedback from the community on the code and/or approach taken.
&lt;/p&gt;


</description><pubDate>Mon, 08 Sep 2008 03:47:24 -0500</pubDate><guid>http://paltman.com/2008/sep/08/shifting-bits-another-django-blog-engine/</guid></item><item><title>Django Blog in the Works</title><link>http://paltman.com/2008/sep/03/django-blog-in-the-works/</link><description>
&lt;p&gt;I am &lt;a href="http://paltman.com/2008/02/02/i-want-to-move-my-blog-to-django/"&gt;previously stated my desire about rebuilding&lt;/a&gt; &lt;a href="http://paltman.com"&gt;Shifting Bits&lt;/a&gt; into a Django-based blog, but it has been really slow going due to other time commitments.
&lt;/p&gt;
&lt;p&gt;Over the weekend, I started cutting out a &lt;a href="http://paltman.com/wp-content/uploads/2008/09/shifting-bits-by-patrick-altman-1-4.png"&gt;fresh new template&lt;/a&gt; and a migration script to get my data export from &lt;a href="http://wordpress.org/"&gt;WordPress&lt;/a&gt; into my Post model (borrowing heavily from &lt;a href="http://oebfare.com/"&gt;Brian Rosner&lt;/a&gt;'s &lt;a href="http://github.com/brosner/oebfare/tree/master"&gt;oebfare&lt;/a&gt; -- why invent when you can steal).
&lt;/p&gt;
&lt;p&gt;Here is a preview of what is to come, hopefully sooner rather than later:
&lt;/p&gt;
&lt;div style="text-align:center;"&gt;&lt;a style="text-decoration: none; border:0px;" href="http://paltman.com/wp-content/uploads/2008/09/shifting-bits-by-patrick-altman-1-4.png"&gt;&lt;img src="http://paltman.com/wp-content/uploads/2008/09/shifting-bits-by-patrick-altman-1-41.png" alt="Shifting Bits by Patrick Altman-1-4.png.png" border="0" width="436" height="439" /&gt;&lt;/a&gt;&lt;/div&gt;



</description><pubDate>Wed, 03 Sep 2008 04:59:06 -0500</pubDate><guid>http://paltman.com/2008/sep/03/django-blog-in-the-works/</guid></item><item><title>Django Group in Nashville</title><link>http://paltman.com/2008/aug/30/django-group-in-nashville/</link><description>
&lt;p&gt;I was pretty pumped to get the invite from &lt;a href="http://treypiepmeier.com/"&gt;Trey Piepmeier&lt;/a&gt; tonight about trying to start a local (Nashville, TN) Django meetup/group.
&lt;/p&gt;
&lt;p&gt;If you are in the area, &lt;a href="http://tinyurl.com/6oxpsr"&gt;head on over and sign up&lt;/a&gt;!
&lt;/p&gt;


</description><pubDate>Sat, 30 Aug 2008 03:53:17 -0500</pubDate><guid>http://paltman.com/2008/aug/30/django-group-in-nashville/</guid></item><item><title>New App: Django and AWS</title><link>http://paltman.com/2008/aug/26/new-app-django-and-aws/</link><description>
&lt;p&gt;I have started a new app over on &lt;a href="http://github.com"&gt;github&lt;/a&gt; called &lt;a href="http://github.com/paltman/django-aws/"&gt;django-aws&lt;/a&gt;.  It's pretty bare bones right now but wanted to announce it earlier rather than later as I am hoping to:
&lt;/p&gt;
&lt;ul&gt;
 &lt;li&gt;
     Get some folks who might be interested to help me out.
 &lt;/li&gt;

 &lt;li&gt;
     Get some eyeballs on it for recommendations for how to (or how to not) do certain things.
 &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I would appreciate any feedback or help that I might be able to scrounge up!  This app will have a strict dependency on &lt;a href="http://boto.googlecode.com"&gt;boto&lt;/a&gt; which is a really cool project provides the de facto way for interacting with Amazon Web Services in the Python language.
&lt;/p&gt;


</description><pubDate>Tue, 26 Aug 2008 03:25:40 -0500</pubDate><guid>http://paltman.com/2008/aug/26/new-app-django-and-aws/</guid></item><item><title>Changeset 7967: NFA Branch Merged into Trunk</title><link>http://paltman.com/2008/jul/19/changeset-7967-nfa-branch-merged-into-trunk/</link><description>
&lt;p&gt;I and a host of other folks have been waiting anxiously for &lt;a href="http://code.djangoproject.com/changeset/7967"&gt;this merge&lt;/a&gt; for a while now.  Excited to see it happen tonight.
&lt;/p&gt;
&lt;p&gt;Good job, &lt;a href="http://oebfare.com"&gt;Brian Rosner&lt;/a&gt; et al.
&lt;/p&gt;


</description><pubDate>Sat, 19 Jul 2008 04:00:10 -0500</pubDate><guid>http://paltman.com/2008/jul/19/changeset-7967-nfa-branch-merged-into-trunk/</guid></item><item><title>GitHub Enables Markdown Documentation</title><link>http://paltman.com/2008/jul/15/github-enables-markdown-documentation/</link><description>
&lt;p&gt;I have been desiring to have the documentation that I write for my various projects on &lt;a href="http://github.com"&gt;GitHub&lt;/a&gt; render to HTML when using a &lt;code&gt;.markdown&lt;/code&gt; extension, just like they support doing for special files like &lt;code&gt;README.markdown&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;At first, I thought they'd eventually get around to it and that is the best I could hope for as surely they are too busy to respond to a non-paying customer like me.  Then I learned they the used the &lt;a href="http://logicalawesome.lighthouseapp.com/projects/8570-github"&gt;Lighthouse&lt;/a&gt; ticket system to manage their project and took public submissions for features.
&lt;/p&gt;
&lt;p&gt;Before logging a feature request I did some searching and found &lt;a href="http://logicalawesome.lighthouseapp.com/projects/8570-github/tickets/479-render-marked-up-files-like-readmes"&gt;a ticket already&lt;/a&gt; out there requesting exactly this same feature that I wanted.  So I just added my own comments to the ticket to give it a +1.
&lt;/p&gt;
&lt;p&gt;After a little back and forth I learned it was implemented tonight (just a week after my first comment).  Good to see such responsive development.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a href="http://github.com/paltman/django-aws/tree/master/docs/tags.markdown"&gt;An example of this feature&lt;/a&gt; can be found in my &lt;a href="http://github.com/paltman/django-aws/"&gt;django-aws&lt;/a&gt; project which is simple app to provide some template tags to provide Amazon Web Services information a la &lt;a href="http://boto.googlecode.com"&gt;boto&lt;/a&gt;.
&lt;/p&gt;


</description><pubDate>Tue, 15 Jul 2008 03:11:19 -0500</pubDate><guid>http://paltman.com/2008/jul/15/github-enables-markdown-documentation/</guid></item><item><title>Ordering Edit Inlines</title><link>http://paltman.com/2008/jul/10/ordering-edit-inlines/</link><description>
&lt;p&gt;&lt;img style="padding-left:10px;" src="http://paltman.com/wp-content/uploads/2008/07/289142843-b04124fd3b-m.jpg" alt="289142843_b04124fd3b_m.jpg" border="0" width="240" height="180" align="right" /&gt;In my continued experimentation with the &lt;a href="http://code.djangoproject.com/wiki/NewformsAdminBranch"&gt;newforms-admin&lt;/a&gt; branch of Django, I wanted to figure out how to order fields of an inline.  Looking at the &lt;a href="http://code.djangoproject.com/browser/django/branches/newforms-admin/docs/admin.txt#L503"&gt;documentation for inlines&lt;/a&gt; I saw there was not an &lt;code&gt;ordering&lt;/code&gt; field.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I had thought that there was but it turns out I was just mistaken in the object hierarchy.  &lt;code&gt;InlineModelAdmin&lt;/code&gt; inherits from &lt;code&gt;BaseModelAdmin&lt;/code&gt; the same as &lt;code&gt;ModelAdmin&lt;/code&gt; -- I was thinking that &lt;code&gt;InlineModelAdmin&lt;/code&gt; inherited from &lt;code&gt;ModelAdmin&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;Therefore, I had to determine a way to accomplish this via some spelunking through the code.  At first, I thought I'd just create my own template by inheriting or copying the &lt;code&gt;tabular.html&lt;/code&gt; template.  After looking at it, I determined that I didn't want to figure out how to do a &lt;code&gt;regroup&lt;/code&gt; on &lt;code&gt;inline_admin_formset&lt;/code&gt; or if even that was the proper way to try to order things in that template.
&lt;/p&gt;
&lt;p&gt;After a few minutes in the code I realized that I could just subclass &lt;code&gt;BaseInlineFormset&lt;/code&gt; and specify the fields that I wanted to order by (in this example I will use &lt;code&gt;start_time&lt;/code&gt; and &lt;code&gt;end_time&lt;/code&gt;:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from django.contrib import admin
from django.newforms.models import BaseInlineFormset

class MyOrderedFormset(BaseInlineFormset):
    def get_queryset(self):
        qs = super(SessionInlineFormset, self).get_queryset()
        return qs.order_by('start_time', 'end_time')

class MyOrderedInline(admin.TabularInline):
    model = MyModel
    extra = 1
    formset = MyOrderedFormset
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That's it.  Now after that section of inlines are ordered by &lt;code&gt;start_time&lt;/code&gt; and &lt;code&gt;end_time&lt;/code&gt;.
&lt;/p&gt;


</description><pubDate>Thu, 10 Jul 2008 03:37:06 -0500</pubDate><guid>http://paltman.com/2008/jul/10/ordering-edit-inlines/</guid></item><item><title>Managing Database Changes in Django</title><link>http://paltman.com/2008/jul/03/managing-database-changes-in-django/</link><description>

&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;&lt;img src="http://paltman.com/wp-content/uploads/2008/07/migration.jpg" alt="migration.jpg" style="margin-left: 10px; " border="0" width="250"  align="right" /&gt;Managing database changes in a team environment working on a django project can be complicated.  I would imagine that there is no one size fits all solution and it would depend on team size and configuration, production database size, etc.
&lt;/p&gt;
&lt;p&gt;What I will outline here is a solution I developed for a small team that I work with on a django based web application.  So far it has worked really well for allowing us to streamline database changes so we can stay in sync, deploy easily, and add small tweaks to the database (indexing, data manipulation, etc.) that is semi-automated.
&lt;/p&gt;
&lt;p&gt;The idea is based partly on Rails database migrations (though not has sleek and well put together) and a database versioning system that was used on a team that I have worked on previously using MS SQL in a corporate environment and a fairly decent team size.  In one sense it is not nearly as well put together as either of these two solutions, but at the same time, it is pretty much hands off and has been working well for us for a number of months now.
&lt;/p&gt;

&lt;h4&gt;Why not just use syncdb?&lt;/h4&gt;
&lt;p&gt;As nice as &lt;code&gt;python manage.py syncdb&lt;/code&gt; is when the project is getting started and is still in early phases, it becomes less and less useful, mostly in handling schema changes.  Since syncdb only creates a model if it doesn't already exist in the database, we found ourselves outputting sql with &lt;code&gt;python manage.py sql APP_NAME&lt;/code&gt; and then making adhoc &lt;code&gt;ALTER TABLE&lt;/code&gt; scripts from the &lt;code&gt;CREATE&lt;/code&gt; statements and passing them around to each other and then trying to remember the order to apply them in production.
&lt;/p&gt;
&lt;p&gt;Furthermore, syncdb left us without a way to alter data, add indexes, remove indexes, etc.  Granted that wasn't it's intent and I am certainly not trying to beat up syncdb -- it does what it does well.
&lt;/p&gt;

&lt;h4&gt;The Solution&lt;/h4&gt;
&lt;p&gt;In order to address this, it seemed the most natural thing was to have some structured and ordered way to write SQL scripts that were applied in a uniform manner so that it was repeatable.  This way we could run on our development databases, on test databases, and in deployment on production all the same way.
&lt;/p&gt;
&lt;p&gt;First step to achieve this was to version the database.  This is accomplished with a simple table that will keep track of what it has executed along with some other metadata primarily for reference purposes.
&lt;/p&gt;
&lt;pre&gt;
CREATE TABLE `versions` (
    `version` VARCHAR(200) NOT NULL, 
    `date_created` DATETIME NOT NULL,
    `sql_executed` LONGTEXT NULL,
    `svn_version` int null
);
&lt;/pre&gt;

&lt;p&gt;In order to populate this table and keep versions consistent, the naming scheme of the sql scripts should follow something that lends itself to easy sorting:
&lt;/p&gt;
&lt;pre&gt;
YYYYMMDD-##.sql
&lt;/pre&gt;

&lt;p&gt;where pound signs are zero-padded integers of the changes for the day.  In a team environment, it is probable that two people might be working on a database change at the same time and therefore would be use 01.  Whoever committed first would be able to keep the 01, the other developer would get a conflict message and need to rename his script to 02.
&lt;/p&gt;
&lt;p&gt;These scripts live in a &lt;code&gt;db/&lt;/code&gt; folder in our project.  The name of this folder is not important, but it is important to keep all the sql scripts in a folder not mixed in with other files.
&lt;/p&gt;
&lt;p&gt;To tie it all together there is s simple python script that gets the list of applied changes from the database, gets a list of files in the current directory in order, filters out the ones that have been applied and then processes the remaining scripts.  In processing the scripts, it opens each script and splits script down into individual statements (splitting on the semicolon).  After execution of an entire script file is complete, the &lt;code&gt;versions&lt;/code&gt; table is updated to reflect the applied version.
&lt;/p&gt;
&lt;p&gt;Running &lt;code&gt;python upgrade.py&lt;/code&gt; by itself will simply print to standard output all the statements it plans to execute, so that they can be reviewed.  Running &lt;code&gt;python upgrade.py --execute&lt;/code&gt; will actually execute the scripts.
&lt;/p&gt;
&lt;p&gt;If an error was found in executing a statement, processing stops immediately.
&lt;/p&gt;
&lt;p&gt;You can find &lt;code&gt;upgrade.py&lt;/code&gt; in &lt;a href="http://www.djangosnippets.org/snippets/849/"&gt;Django Snippet 849&lt;/a&gt;.
&lt;/p&gt;

&lt;h4&gt;Improvements&lt;/h4&gt;
&lt;p&gt;There are lots of improvements to this script that I'd like to add if I got around to it.    The ones I'd like to see most is support for &amp;quot;rollbacks&amp;quot;.  Comments and suggestions are most welcome!
&lt;/p&gt;


</description><pubDate>Thu, 03 Jul 2008 17:24:01 -0500</pubDate><guid>http://paltman.com/2008/jul/03/managing-database-changes-in-django/</guid></item><item><title>Edit Inline Support for Generic Relations</title><link>http://paltman.com/2008/jun/30/edit-inline-support-for-generic-relations/</link><description>

&lt;h4&gt;Introduction&lt;/h4&gt;
&lt;p&gt;&lt;img src="http://paltman.com/wp-content/uploads/2008/06/234819164-513d775b4c-m.jpg" alt="234819164_513d775b4c_m.jpg" border="0" width="240" height="217" align="right" /&gt;I've recently (past week or so) been digging into the &lt;a href="http://code.djangoproject.com/wiki/NewformsAdminBranch"&gt;newforms-admin branch of django&lt;/a&gt;.  I am really looking forward to this code line getting merged into trunk as there are tons of great work in this branch.  I especially like the separation of the admin code from the models.
&lt;/p&gt;
&lt;p&gt;Well, I'll get to my point.  &lt;br /&gt;
&lt;/p&gt;

&lt;h4&gt;The Problem&lt;/h4&gt;
&lt;p&gt;I needed to be able to edit child records in the admin that were children through the use of &lt;a href="http://www.djangoproject.com/documentation/models/generic_relations/"&gt;GenericRelations&lt;/a&gt;.  I was told &lt;a href="http://code.google.com/p/django-genericadmin/"&gt;about a solution on Google Code called django-genericadmin&lt;/a&gt;, but it seemed dead and I could not get it to work.
&lt;/p&gt;
&lt;p&gt;The thing that seemed the closest to working was a patch on &lt;a href="http://code.djangoproject.com/ticket/4667"&gt;ticket 4667&lt;/a&gt; by Honza Kral and a variation on this patch in the &lt;a href="http://www.djangosnippets.org/snippets/765/"&gt;Django Snippet 765&lt;/a&gt;.  Neither of these worked for &lt;a href="http://code.djangoproject.com/changeset/7771"&gt;r7771 of branches/newforms-admin&lt;/a&gt;.
&lt;/p&gt;

&lt;h4&gt;The Solution&lt;/h4&gt;
&lt;p&gt;I put the 765 snippet in a file called &lt;code&gt;generic.py&lt;/code&gt; in the root of the django project I was working on and fiddled with it until I got it working.  I ended up needing to change an import, fix some variable names, and change the argument list order in one of the &lt;strong&gt;init&lt;/strong&gt; methods.  I also added the &lt;code&gt;can_order&lt;/code&gt; and &lt;code&gt;can_delete&lt;/code&gt; options to the &lt;code&gt;GenericInlineModelAdmin&lt;/code&gt; class.
&lt;/p&gt;
&lt;p&gt;After I got it working isolated in &lt;code&gt;generic.py&lt;/code&gt;, I then added the code to the &lt;code&gt;django/contrib/admin/options.py&lt;/code&gt; file and created a &lt;a href="http://code.djangoproject.com/attachment/ticket/4667/4667-generic-edit-inline.patch"&gt;new patch (after testing locally of course)&lt;/a&gt;.  This patch has since been added to &lt;a href="http://code.djangoproject.com/ticket/4667"&gt;ticket 4667&lt;/a&gt;.  I also posted the full version that I had running in &lt;code&gt;generic.py&lt;/code&gt; in &lt;a href="http://www.djangosnippets.org/snippets/832/"&gt;snippet 832&lt;/a&gt; in case someone wants to use it without patching their newforms-admin branch.
&lt;/p&gt;

&lt;h4&gt;Example of How to Use&lt;/h4&gt;
&lt;p&gt;In order to get a sense for how to make use of this functionality, imagine you have a songs app that you use to model and record details about songs, you have built this generically so you can reuse it wisely in a number of different projects.  One project in particular has a need to to reference song data.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;You are building a home media inventory system and decide you want to catalog both your albums as well as your DVD collection, however, you want the ability to record what songs exist on both your albums as well as your DVDs as you are a fanatic about soundtracks.
&lt;/p&gt;
&lt;p&gt;So you have the following models (abbreviated for clarity):
&lt;/p&gt;
&lt;pre&gt;
# Media Collection App

class Album(models.Model):
    ...

class DVD(models.Model):
    ...

# Song App

class Song(models.Model):
    ...
&lt;/pre&gt;

&lt;p&gt;Since you want to enable your &lt;code&gt;Song&lt;/code&gt; model to relate to two other models generically, you decide to use Generic Relations like so:
&lt;/p&gt;
&lt;pre&gt;
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

class Song(models.Model):
    ...
    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField()
    content_object = generic.GenericForeignKey()
&lt;/pre&gt;

&lt;p&gt;and then on the models that you want to have 0 to Many child records that are songs:
&lt;/p&gt;
&lt;pre&gt;
from myproject.song.models import Song
from django.contrib.contenttypes import generic

class Album(models.Model):
    ...
    songs = generic.GenericRelation(Song)

class DVD(models.Model):
    ...
    songs = generic.GenericRelation(Song)
&lt;/pre&gt;

&lt;p&gt;Now that's all you need to do if you didn't care about editing the data in the admin, however, since that is not the point of the article, here is what you need to do in your &lt;code&gt;admin.py&lt;/code&gt; in the app that contains &lt;code&gt;Album&lt;/code&gt; and &lt;code&gt;DVD&lt;/code&gt;:
&lt;/p&gt;
&lt;pre&gt;
...
from myproject.song.models import Song
from myproject.generic import GenericTabularInline
### OR ###

### from django.contrib.admin.options import GenericTabularInline



class SongInline(GenericTabularInline):
    model = Song
    extra = 2 
    ct_field_name = 'content_type'
    id_field_name = 'object_id'

class AlbumOptions(admin.ModelAdmin):
    model = Album
    inlines = (SongInline,)

class DVDOptions(admin.ModelAdmin):
    model = DVD
    inlines = (SongInline,)

admin.site.register(Album, AlbumOptions)
admin.site.register(DVD, DVDOptions)
&lt;/pre&gt;

&lt;p&gt;Now you should be able to add/remove songs when editing an &lt;code&gt;Album&lt;/code&gt; or &lt;code&gt;DVD&lt;/code&gt; in your admin.
&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Fixed typo in code sample above in setting the GenericForeignKey() -- thanks FunkyBob!
&lt;/p&gt;


</description><pubDate>Mon, 30 Jun 2008 04:12:33 -0500</pubDate><guid>http://paltman.com/2008/jun/30/edit-inline-support-for-generic-relations/</guid></item><item><title>Django OperationalError Debugging</title><link>http://paltman.com/2008/may/11/django-operationalerror-debugging/</link><description>
&lt;p&gt;So on one of our test servers I was doing some heavy performance testing when I noticed a strange OperationalError exception message in the Debug console for Django:
&lt;/p&gt;
&lt;img src="http://paltman.com/wp-content/uploads/2008/05/picture-3.png" alt="Picture 3.png" border="0" width="448" height="36" /&gt;

&lt;p&gt;I went digging around and sure enough I had all kinds of locks when I attempted:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysql&amp;gt; SHOW PROCESSLIST;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So next I checked the status of the free space available to learn than the partition that the mysql data was on was completely full.  So, shutdown mysql and relocated the data to another partition with plenty of room:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysqladmin shutdown
mv /usr/local/apache/var/* /new/location/for/files/
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then I changed &lt;code&gt;/etc/my.cnf&lt;/code&gt; so that it had the following lines edited or amended:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[mysqld_safe]
datadir = /new/location/for/files/
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Make sure that the ib_logfile files don't remain in the new location:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;rm /new/location/for/files/ib_logfile*
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now restart mysql and verify that everything is working:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysqld_safe &amp;amp;
echo &amp;quot;create database testdatabase;&amp;quot; | mysql
echo &amp;quot;show databases;&amp;quot; | mysql
&lt;/code&gt;&lt;/pre&gt;

</description><pubDate>Sun, 11 May 2008 06:05:16 -0500</pubDate><guid>http://paltman.com/2008/may/11/django-operationalerror-debugging/</guid></item><item><title>A Default Bug in Django</title><link>http://paltman.com/2008/may/07/a-default-bug-in-django/</link><description>
&lt;p&gt;Not to say that this is a bug in django but rather a bug in how I had written some of my models.
&lt;/p&gt;
&lt;p&gt;Just wanted to point out a quick tip for anyone else who may have done the same thing as me as well as for any of the django experts out there that might suggest a better way.
&lt;/p&gt;
&lt;p&gt;What was happening was that I began to notice a wild discreptancy between two datetime columns in several models.  They should have been identical, however, they were both getting their dates differently:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;...
date_column_one = models.DateTimeField(default=datetime.now())
date_column_two = models.DateTimeField(auto_now_add=True)
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;What seems to be happening with this configuration is that datetime.now() is executed once when the server starts (and/or the module is imported) instead of what I thought would happen when I initially wrote these and that datetime.now() would get executed anytime an instance of the model was created and saved as a new record.
&lt;/p&gt;
&lt;p&gt;My solution was to override the save method:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;...
date_column_one = models.DateTimeField()
...
def save(self):
    if not self.id:
        self.date_column_one = datetime.now()
    super(MyModel, self).save()
...
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I am sure there is probably a better way and if you know of one, please leave a comment or send me an email and let me know!
&lt;/p&gt;


</description><pubDate>Wed, 07 May 2008 22:54:25 -0500</pubDate><guid>http://paltman.com/2008/may/07/a-default-bug-in-django/</guid></item><item><title>Keeping ContentTypes and Permissions Updated without syncdb</title><link>http://paltman.com/2008/apr/11/keeping-contenttypes-and-permissions-updated-without-syncdb/</link><description>
&lt;p&gt;In managing releases to a production django project, I find myself using &lt;code&gt;python manage.py sqlall APPNAME&lt;/code&gt; to put the sql needed in a script for any new models, and then writing the ALTER or DROP statements by hand to also go into the sql scripts.
&lt;/p&gt;
&lt;p&gt;One thing that not running syncdb on production leaves out are the creation of the content type and permission records (if using django.contrib.auth and django.contrib.contenttypes).   It was recommended to me on &lt;code&gt;#django&lt;/code&gt; that I look at each of these apps management.py module to see where they hook into the &lt;code&gt;post_syncdb&lt;/code&gt; signal.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;In doing so I discovered some methods that I could just call from python and keep both my permissions and content types up to date:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;from django.core.management import setup_environ
try:
    import settings
except ImportError:
    import sys
    sys.stderr.write(&amp;quot;Couldn't find the settings.py module.&amp;quot;)
    sys.exit(1)

setup_environ(settings)

# Add any missing content types
from django.contrib.contenttypes.management \
    import create_all_contenttypes 
create_all_contenttypes()

# Add any missing permissions
from django.contrib.auth.management import create_permissions
from django.db.models import get_apps
for app in get_apps():
    create_permissions(app, None, 2)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Enjoy.
&lt;/p&gt;


</description><pubDate>Fri, 11 Apr 2008 16:16:41 -0500</pubDate><guid>http://paltman.com/2008/apr/11/keeping-contenttypes-and-permissions-updated-without-syncdb/</guid></item><item><title>I Want to Move My Blog to Django</title><link>http://paltman.com/2008/feb/03/i-want-to-move-my-blog-to-django/</link><description>
&lt;p&gt;Oh how I long to move this blog off of WordPress and onto something I build (or cull together) on top of the Django platform.  It feels like it is mostly pulling together a host of different apps that are already written:
   &lt;ul&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/django-tagging/"&gt;django-tagging&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://code.djangoproject.com/wiki/UsingFreeComment"&gt;Comments&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/django-comment-utils/"&gt;Comment Utils&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/django-pingback/"&gt;django-pingback&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://www.djangoproject.com/documentation/add_ons/#markup"&gt;Markup&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://www.djangoproject.com/documentation/syndication_feeds/"&gt;Syndication&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
   That leaves a core part of the blog to write -- something to store the actual entries and then a URL scheme to display different levels of archives and individual posts.  Of course, this schemes needs not to break current links.
&lt;/p&gt;
&lt;p&gt;This led me to check out what already might exist on Google Code and found these (limited to the most active):
   &lt;ul&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/waggly-blog/"&gt;waggly-blog&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/blogmaker/"&gt;blogmaker&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/django-basic-blog/"&gt;django-basic-blog&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/django-diario/"&gt;django-diario&lt;/a&gt;&lt;/li&gt;
       &lt;li&gt;&lt;a href="http://code.google.com/p/blogango/"&gt;blogango&lt;/a&gt;&lt;/li&gt;
   &lt;/ul&gt;
   All are basically the same, with slightly different inclusions and approaches to this core &amp;quot;Blog&amp;quot; feature.
&lt;/p&gt;
&lt;p&gt;Lastly, a feature I'd want to implement (&lt;a href="http://jerakeen.org/blog/2006/10/adding-a-metaweblog-interface-to-django/"&gt;if there isn't already an app out there supporting it that I can integrate&lt;/a&gt;) is a MetaWeblog API interface so that I can use MarsEdit, my favorite blog publish.  Then all that would be left would be figuring out the data structure of WordPress and migrate over all my content (this is the only part that I am not looking forward to).
&lt;/p&gt;


</description><pubDate>Sun, 03 Feb 2008 02:08:05 -0500</pubDate><guid>http://paltman.com/2008/feb/03/i-want-to-move-my-blog-to-django/</guid></item><item><title>Django People Rocks</title><link>http://paltman.com/2008/jan/30/django-people-rocks/</link><description>
&lt;p&gt;This is a &lt;a href="http://djangopeople.net/"&gt;really cool site&lt;/a&gt; for getting a sense for the django community in your community.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I just put &lt;a href="http://djangopeople.net/paltman/"&gt;my profile up&lt;/a&gt;.  We need a micro-format (maybe &lt;a href="http://microformats.org/wiki/hcard"&gt;hcard&lt;/a&gt; would work) for &amp;quot;profiles&amp;quot; so the same set of metadata about ourselves can just be reused at the different &amp;quot;profile sites&amp;quot; that we find ourselves joining.
&lt;/p&gt;


</description><pubDate>Wed, 30 Jan 2008 04:08:14 -0500</pubDate><guid>http://paltman.com/2008/jan/30/django-people-rocks/</guid></item><item><title>Breaking Apart Models in Django</title><link>http://paltman.com/2008/jan/29/breaking-apart-models-in-django/</link><description>
&lt;p&gt;Depending on the size of your &lt;code&gt;models.py&lt;/code&gt;, you may find it becoming 
   unwieldy, especially if you are on a team with multiple developers are editing 
   the same file, increasing the odds for merge conflicts.
&lt;/p&gt;
&lt;p&gt;There are two parts to breaking up a large module in Django.  The first is a 
   purely Python convention where you break apart the file into multiple files 
   and create a subdirectory for the name of the original module so your 
   &lt;code&gt;models.py&lt;/code&gt; file becomes:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;models/__init__.py
models/module1.py
models/modlue2.py
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Inside your &lt;code&gt;__init__.py&lt;/code&gt; you'll want to import from your 
   &lt;code&gt;module1.py&lt;/code&gt; and &lt;code&gt;module2.py&lt;/code&gt; modules and add those 
   imported objects to &lt;code&gt;__all__&lt;/code&gt;:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# __init__.py
from app.models.module1 import MyClass
from app.models.module2 import AnotherClass, function_one
__all__ = ['MyClass', 'AnotherClass', 'function_one']
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now that you have taken care of the Python part of this exercise, you'll need 
   to do a couple &lt;i&gt;tricks&lt;/i&gt; to get your models importing properly in the 
   context of your django project.
&lt;/p&gt;
&lt;p&gt;It involves adding a couple o attributes to the &lt;code&gt;Meta&lt;/code&gt; inner class. 
   Thanks to &lt;a href="http://collingrady.com/"&gt;Collin Grady (aka Magus on #django on irc.freenode.net)&lt;/a&gt; for pointing these tips out to me:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;class MyClass:
    ...
    class Meta:
        app_name = 'myappname'
        db_table = 'myappname_myclass'
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now you should have a better code base that causes less contention and makes 
   it faster to locate the models you are looking for.
&lt;/p&gt;

&lt;h3&gt;Update&lt;/h3&gt;
&lt;p&gt;As has been pointed out to me in the comments as well as one #djano today, 
   I got &amp;quot;Empty&amp;quot; and &amp;quot;Magus&amp;quot; mixed up with their real names.  Much apologies for 
   any and all confusion this might have caused.
&lt;/p&gt;

&lt;h3&gt;Update 2&lt;/h3&gt;
&lt;p&gt;As pointed out in some of the recent comments below, this post was &lt;em&gt;corrupted&lt;/em&gt;
   when I enabled the markdown plugin for wordpress.  It is treating all posts I 
   have ever written as markdown which is not right but I have not the energy nor 
   the inclination to go back in time and update all my old posts.  That being 
   said, I really love markdown for my posting so I'll keep the plugin activated.
&lt;/p&gt;


</description><pubDate>Tue, 29 Jan 2008 23:48:55 -0500</pubDate><guid>http://paltman.com/2008/jan/29/breaking-apart-models-in-django/</guid></item><item><title>Django Flatpages with Debug Set to False</title><link>http://paltman.com/2008/jan/11/django-flatpages-with-debug-set-to-false/</link><description>
&lt;p&gt;After deploying a site I am working on to a preview server running apache/mod_python, it was the first time serving up the site in something other than &lt;code&gt;python manage.py runserver&lt;/code&gt;.
&lt;/p&gt;
&lt;p&gt;I worked through a number of issues that I found quick answers for on the &lt;a href="http://www.djangoproject.com/documentation/faq/"&gt;FAQ site for django&lt;/a&gt;, but one in particular I couldn't figure out, but eventually got pointed to the obvious in the &lt;a href="irc://irc.freenode.net/django"&gt;irc channel for django&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;The site has a number of &lt;a href="http://www.djangoproject.com/documentation/flatpages/"&gt;flatpages&lt;/a&gt;, which I have come to learn is a middleware trick where when a url doesn't match anything and right before a 404 normally would be thrown giving the Page Not Found error, it checks against any flatpage &amp;quot;urls&amp;quot; you have registered the database with static content.  If it finds something it will return that content, if not the 404 bubbles back out of the middleware and goes to the user.
&lt;/p&gt;
&lt;p&gt;Everything worked fine with DEBUG=True in my settings.py file.  However, when I changed it to DEBUG=False, I got a 500 Internal Server Error but then when I looked at my error.log, I could see a django exception saying it couldn't find the 404.html.
&lt;/p&gt;
&lt;p&gt;This made no sense to me at all.  Why would it be looking for a 404.html when it doesn't need it yet (the flatpage middleware should have intercepted it before it looked for a 404.html template, was my thinking).  It was suggested to me in the irc channel that I create a 404.html (for more reasons that just fixing this problem).
&lt;/p&gt;
&lt;p&gt;So to just test that theory, I ran &lt;code&gt;touch templates/404.html&lt;/code&gt; -- it worked!
&lt;/p&gt;


</description><pubDate>Fri, 11 Jan 2008 03:34:00 -0500</pubDate><guid>http://paltman.com/2008/jan/11/django-flatpages-with-debug-set-to-false/</guid></item><item><title>Django Custom Filter Registration</title><link>http://paltman.com/2008/jan/10/django-custom-filter-registration/</link><description>
&lt;p&gt;I wrestled with this one for about an hour last night before realizing it was rather simple.  Following the &lt;a href="http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-filters"&gt;instructions to create a custom template filter&lt;/a&gt;, I thought everything was simple and made since until when I tried to load the page to test it.  &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;The page spewed a stack trace telling me that it couldn't find the custom filter I was trying lo load with:
&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
   {% load website.app.custom_filters %}&lt;br /&gt;
   {% filter htmlcompress %}&lt;br /&gt;
   ...&lt;br /&gt;
   {% endfilter %}&lt;br /&gt;
   &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;I then realized that I had registered it like so:
&lt;/p&gt;
&lt;code&gt;


&lt;h1&gt;website/app/template_tags/custom_filters.py&lt;br /&gt;&lt;/h1&gt;
&lt;p&gt;from django import template&lt;br /&gt;
   register = template.Library()&lt;br /&gt;
   @register.filter(&amp;quot;htmlcompress&amp;quot;)
   &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;It seems that there is some magic that occurs that loads the custom_filters.py module in a global namespace so that doing this in my base template works:
&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
   {% load custom_filters %}&lt;br /&gt;
   {% filter htmlcompress %}&lt;br /&gt;
   ...&lt;br /&gt;
   {% endfilter %}&lt;br /&gt;
   &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;Thought I'd post this in case I am not the only new person to django wrestling with this.
&lt;/p&gt;


</description><pubDate>Thu, 10 Jan 2008 16:57:41 -0500</pubDate><guid>http://paltman.com/2008/jan/10/django-custom-filter-registration/</guid></item><item><title>Running Multiple Django Versions in Development</title><link>http://paltman.com/2008/jan/08/running-multiple-django-versions-in-development/</link><description>
&lt;p&gt;I have needed to use different revisions of the django trunk at different points in time (in testing locally a new revision before upgraded in production, or working on two different projects that deploy to two different production environments, etc).
&lt;/p&gt;
&lt;p&gt;There may be a better way, but how I have handled it pretty painlessly is by running this script:
&lt;/p&gt;
&lt;code&gt;


&lt;h1&gt;!/bin/bash&lt;/h1&gt;
&lt;p&gt;rm -rf /[YOUR PATH]/$1
   svn co -r $1 http://code.djangoproject.com/svn/django/trunk/django /[YOUR PATH]/$1
   sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django
   sudo rm /usr/bin/django-admin
   sudo ln -s /[YOUR PATH]/$1/ /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django
   sudo ln -s /[YOUR PATH]/$1/bin/django-admin.py /usr/bin/django-admin
   echo &amp;quot;Switched to&amp;quot; $1
   &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;It takes a single parameter, a revision number.
&lt;/p&gt;

&lt;h1&gt;./switch.sh 7000&lt;/h1&gt;
&lt;p&gt;I run this script from within a directory in my home directory called &amp;quot;django&amp;quot;.
&lt;/p&gt;
&lt;p&gt;You will likely need to change the paths in the script above if you are not running Python 2.5 on Mac OSX.  Also, remember to substitute &amp;quot;[YOUR PATH]&amp;quot; for the base location of where you want to store the django code.
&lt;/p&gt;


</description><pubDate>Tue, 08 Jan 2008 17:58:20 -0500</pubDate><guid>http://paltman.com/2008/jan/08/running-multiple-django-versions-in-development/</guid></item><item><title>Cool Django Apps / Frameworks / Add-Ons</title><link>http://paltman.com/2008/jan/07/cool-django-apps-frameworks-add-ons/</link><description>
&lt;p&gt;Ran across three really cool looking extensions to &lt;a href="http://www.djangoproject.com"&gt;django&lt;/a&gt;:
   &lt;ul&gt;
   &lt;li&gt;&lt;a href="http://www.djangoproject.com/documentation/databrowse/"&gt;databrowse&lt;/a&gt;&lt;br /&gt;&lt;blockquote&gt;Databrowse is a Django application that lets you browse your data.
   &lt;br /&gt;&lt;br /&gt;
   As the Django admin dynamically creates an admin interface by introspecting your models, Databrowse dynamically creates a rich, browsable Web site by introspecting your models.&lt;/blockquote&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="http://www.djangoproject.com/documentation/sitemaps/"&gt;sitemap&lt;/a&gt;&lt;br /&gt;
   &lt;blockquote&gt;Django comes with a high-level sitemap-generating framework that makes creating sitemap XML files easy.&lt;/blockquote&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href="http://www.djangoproject.com/documentation/webdesign/"&gt;webdesign&lt;/a&gt;&lt;br /&gt;
   &lt;blockquote&gt;The django.contrib.webdesign package, part of the “django.contrib” add-ons, provides various Django helpers that are particularly useful to Web designers (as opposed to developers).&lt;/blockquote&gt;&lt;/li&gt;
   &lt;/ul&gt;
&lt;/p&gt;
&lt;p&gt;I am anxious to given these items a spin, especially databrowse.
&lt;/p&gt;


</description><pubDate>Mon, 07 Jan 2008 04:06:48 -0500</pubDate><guid>http://paltman.com/2008/jan/07/cool-django-apps-frameworks-add-ons/</guid></item><item><title>Django Fixtures and Flatpage Deployment</title><link>http://paltman.com/2008/jan/07/django-fixtures-and-flatpage-deployment/</link><description>
&lt;p&gt;I was introduced today to the concept and django feature known as Fixtures, while reading my dead-tree version of the &lt;a href="http://djangobook.com/"&gt;new django book&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;I am currently building a small site, fairly simple and mostly static.  I have written an app that is my own take on the flatpages that are in django.contrib (a post on this later) -- I basically needed a little more flexibility for different islands of content.
&lt;/p&gt;
&lt;p&gt;In building this site and setting up the appropriate flatpages in my development, I realized that I am going to need to seed the database when I release to production or else there are going to be a lot of 404 errors.  Also, since the pages are referred to in my menus, I need for the url on the flatpage model to be exact.  It's not that many pages, but still, I thought, there had to be a better way that either manually hand entering all the data, troubleshooting 404s for typos in the url field, or doing any manual exporting of data at the mysql prompt.
&lt;/p&gt;
&lt;p&gt;As if by some divine revelation, I happened across the &lt;a href="http://djangobook.com/en/1.0/appendixG/"&gt;chapter in the book&lt;/a&gt; talking about &lt;code&gt;django-admin &lt;a href="http://www.djangoproject.com/documentation/django-admin/#dumpdata-appname-appname"&gt;dumpdata&lt;/a&gt;/&lt;a href="http://www.djangoproject.com/documentation/django-admin/#loaddata-fixture-fixture"&gt;loaddata&lt;/a&gt;&lt;/code&gt;.  What's cool about this is by dumping the data into a file in source control, you can revision your flatpages (or any other data that is).
&lt;/p&gt;
&lt;p&gt;Here's what I did:
&lt;/p&gt;
&lt;code&gt;


&lt;h1&gt;mkdir fixtures&lt;/h1&gt;

&lt;h1&gt;django-admin dumpdata flatpages --indent=4 &amp;gt; fixtures/flatpages.json&lt;/h1&gt;
&lt;/code&gt;

&lt;p&gt;Remember, I have a local app in my project called flatpages that is my replacement for the contrib version.
&lt;/p&gt;
&lt;p&gt;I tested that this data was usable by changing my setting.py file to use a different database (a new one):
&lt;/p&gt;
&lt;code&gt;


&lt;h1&gt;mysql&lt;/h1&gt;
&lt;p&gt;mysql&amp;gt; create database test_import;
   msyql&amp;gt; exit;
   django-admin loaddata fixtures/flatpages.json
   python manage.py runserver
   &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;Then fired up the browser and there was all my flatpages, perfect!
&lt;/p&gt;


</description><pubDate>Mon, 07 Jan 2008 03:59:23 -0500</pubDate><guid>http://paltman.com/2008/jan/07/django-fixtures-and-flatpage-deployment/</guid></item></channel></rss>
