<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>I make web.
Co-Founder of Pixelcloud.com
Django &amp; Backbone.js consulting.</description><title>Andrew McCloud</title><generator>Tumblr (3.0; @amccloud)</generator><link>http://amccloud.com/</link><item><title>Django 1.5 Custom User GeoManager</title><description>&lt;blockquote&gt;AttributeError: &amp;#8216;GeoManager&amp;#8217; object has no attribute &amp;#8216;get_by_natural_key&amp;#8217;&lt;/blockquote&gt;
&lt;p&gt;Using geo fields on a Django model requires the use of GeoManager. Custom User models require an object manager that implements &lt;a href="https://github.com/django/django/blob/82d4786544e2331b23de468aba875e9600162d76/django/contrib/auth/models.py#L167" target="_blank"&gt;BaseUserManager.get_by_natural_key&lt;/a&gt;. If you&amp;#8217;re trying to add geo fields to your custom User model you&amp;#8217;ll need create a custom manager that mixes a user manager and GeoManager. Lucky us, this is a piece of cake!&lt;/p&gt;
&lt;p class="gist"&gt;&lt;a href="http://gist.github.com/4291351"&gt;&lt;a href="http://gist.github.com/4291351"&gt;http://gist.github.com/4291351&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://amccloud.com/post/37961147683</link><guid>http://amccloud.com/post/37961147683</guid><pubDate>Fri, 14 Dec 2012 20:51:08 -0800</pubDate><category>django</category><category>opensource</category><category>python</category></item><item><title>Create Text &amp; Online Versions of Emails Automatically</title><description>&lt;p&gt;For this i&amp;#8217;ve created &lt;a href="https://github.com/amccloud/django-firstclass" target="_blank"&gt;django-firstclass&lt;/a&gt;. &lt;span&gt;Firstclass is a proxy email backend for Django that allows for global email transformations such as automatically creating a plain text version of html emails or automatically creating an online version of the email that can be read in browser.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;My goal was to have this be a drop in solution requiring no change to a code base. I also wanted this to be flexible enough so that it can work with a wide variety of projects. I accomplished this by adding a middleware pipeline to Django&amp;#8217;s email process. I&amp;#8217;ve bundled a few useful middleware in and plan to add a few more. Creating your own middleware is simple. &lt;/span&gt;Middleware is a single Python class that defines &lt;em&gt;process_message&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;For example if you wanted to create a middleware that would add a tracking pixel to all of your emails:&lt;/p&gt;
&lt;p class="gist"&gt;&lt;a href="http://gist.github.com/3048960"&gt;&lt;a href="http://gist.github.com/3048960"&gt;http://gist.github.com/3048960&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You would then simply add &lt;span&gt;TrackingPixelMiddleware to &lt;/span&gt;&lt;span&gt;&lt;strong&gt;FIRSTCLASS_MIDDLEWARE.&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/amccloud/django-firstclass"&gt;https://github.com/amccloud/django-firstclass&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="img" href="https://github.com/amccloud/django-firstclass"&gt;&lt;img src="http://cl.ly/030a0o092H053S0v1d24/Screen%20Shot%202012-05-11%20at%204.51.41%20PM.png"/&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://amccloud.com/post/26506666072</link><guid>http://amccloud.com/post/26506666072</guid><pubDate>Wed, 04 Jul 2012 12:09:55 -0700</pubDate><category>django</category><category>python</category><category>firstclass</category><category>opensource</category></item><item><title>Quick Optional Model Fields Trick</title><description>&lt;p&gt;This is just something I do now. It&amp;#8217;s DRY, saves a few keystrokes, helps stay under pep8&amp;#8217;s 79 character limit, and improves readability in my opinion.&lt;/p&gt;
&lt;p class="gist"&gt;&lt;a href="http://gist.github.com/1526444"&gt;&lt;a href="http://gist.github.com/1526444"&gt;http://gist.github.com/1526444&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://amccloud.com/post/14903349762</link><guid>http://amccloud.com/post/14903349762</guid><pubDate>Tue, 27 Dec 2011 21:23:00 -0800</pubDate><category>django</category><category>tips</category></item><item><title>My Django 1.4 Project Template</title><description>&lt;p&gt;Django supports &lt;a href="https://docs.djangoproject.com/en/dev/releases/1.4-alpha-1/#custom-project-and-app-templates" target="_blank"&gt;custom project templates&lt;/a&gt; as of 1.4. This is a feature i&amp;#8217;ve been dreaming for and since have created what I consider - and hope - is an improved project template for most. &lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/amccloud/django-project-skel/"&gt;&lt;a href="https://github.com/amccloud/django-project-skel/"&gt;https://github.com/amccloud/django-project-skel/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Changes and additions&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;Global templates, static, and fixtures directory.&lt;/li&gt;
&lt;li&gt;Collects static and media into public/{static,media} respectively.&lt;/li&gt;
&lt;li&gt;Django admin activated by default.&lt;/li&gt;
&lt;li&gt;Django timezone setting changed to UTC for sanity.&lt;/li&gt;
&lt;li&gt;HTML 5 base template with simple 404 and 500 error templates.&lt;/li&gt;
&lt;li&gt;Discourages storing credentials and secrets in the repository.&lt;/li&gt;
&lt;li&gt;Encourages the use of local_settings.py and accompanying __local_settings.py template.&lt;/li&gt;
&lt;li&gt;Encourages the use of virtualenv and virtualenvwrapper.&lt;/li&gt;
&lt;li&gt;Encourages the use of pip and requirements.txt.&lt;/li&gt;
&lt;li&gt;Encourages the use of git.&lt;/li&gt;
&lt;li&gt;Includes a .gitignore for the usual junk.&lt;/li&gt;
&lt;li&gt;Automatically builds a README with installation notes.&lt;/li&gt;
&lt;/ul&gt;&lt;h2&gt;How to use&lt;/h2&gt;
&lt;pre&gt;django-admin.py startproject --template &lt;a href="https://github.com/amccloud/django-project-skel/zipball/master"&gt;https://github.com/amccloud/django-project-skel/zipball/master&lt;/a&gt; --extension py,md yourprojectname
&lt;/pre&gt;
&lt;p&gt;&lt;a href="https://github.com/amccloud/django-project-skel/" target="_blank"&gt;Contribute on GitHub&lt;/a&gt;&lt;/p&gt;</description><link>http://amccloud.com/post/14689947527</link><guid>http://amccloud.com/post/14689947527</guid><pubDate>Fri, 23 Dec 2011 14:34:30 -0800</pubDate><category>django</category><category>1.4</category><category>opensource</category></item></channel></rss>
