<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Musings of an Anonymous Geek &#187; LinuxLaboratory</title>
	<atom:link href="http://www.protocolostomy.com/category/linuxlaboratory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.protocolostomy.com</link>
	<description>Made with only the finest 1's and 0's</description>
	<lastBuildDate>Thu, 03 Nov 2011 04:08:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>New Job, Car, Baby, and Other News</title>
		<link>http://www.protocolostomy.com/2009/10/22/new-job-car-baby-and-other-news/</link>
		<comments>http://www.protocolostomy.com/2009/10/22/new-job-car-baby-and-other-news/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 02:02:48 +0000</pubDate>
		<dc:creator>bkjones</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[LinuxLaboratory]]></category>
		<category><![CDATA[Other Cool Blogs]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Productivity]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.protocolostomy.com/?p=631</guid>
		<description><![CDATA[New Baby! I know this is my geek blog, but geeks have kids too, so first I want to announce the birth of our second daughter, Sadie, who was born on September 15th. She&#8217;s now over a month old. This is the first time I&#8217;ve stayed up late enough to blog about her. Everyone is [...]]]></description>
			<content:encoded><![CDATA[<h3>New Baby!</h3>
<p>I know this is my geek blog, but geeks have kids too, so first I want to announce the birth of our second daughter, Sadie, who was born on September 15th. She&#8217;s now over a month old. This is the first time I&#8217;ve stayed up late enough to blog about her. Everyone is healthy, if slightly sleep-deprived <img src='http://www.protocolostomy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>New Job!</h3>
<p>The day before Sadie&#8217;s birth, I got a call with an offer for a job. A *full-time* job, as a Senior Operations Developer for <a href="http://myyearbook.com">MyYearbook.com</a>. After learning about the cool and very geeky things going on at MyYearbook during the interview process, I couldn&#8217;t turn it down. I started on October 5, and it&#8217;s been a blast digging into all of the cool stuff going on there. While I&#8217;m certainly doing my fair share of PHP code review, maintenance, and general coding, I&#8217;m also getting plenty of hours in working out the Python side of my brain. I&#8217;m finding that while it&#8217;s easier switching gears than I had anticipated, I do make some really funny minor syntax errors, like using dot notation to access object attributes in PHP ;-P</p>
<p>What I find super exciting is something that might turn some peoples&#8217; stomachs: at the end of my first week, I sat back and looked at my monitors to find roughly 15 tabs in Firefox open to pages explaining various tools I&#8217;d never gotten to use, protocols I&#8217;ve never heard of, etc. I had my laptop and desktop both configured with 2 virtual machines for testing and playing with new stuff. I had something north of 25 terminal windows open, and 8 files open in Komodo Edit.</p>
<p>Now THAT, THAT is FUN!</p>
<p>The projects I&#8217;m working on run the gamut from code cleanups that nobody else has had time to do (a good tool for getting my brain wrapped around various parts of the code base), to working on scalability solutions and new offerings involving my background in coding *and* system administration. It&#8217;s like someone cherry-picked a Bay Area startup and dropped it randomly 30 minutes from my house.</p>
<p>My own business is officially &#8220;not taking new clients&#8221;. I have some regular clients that I still do work for, so my &#8220;regulars&#8221; are still being served, but they&#8217;ve all been put on notice that I&#8217;m unavailable until the new year.</p>
<h3>New Car!</h3>
<p>I&#8217;m less excited about the new car, really. I used to drive a Jeep Liberty, and I loved it. However, in early September, before Sadie&#8217;s arrival, it became clear to me that putting two car seats in that beast wasn&#8217;t going to happen. The Jeep is great for drivers, and it has some cargo space. It&#8217;s not a great vehicle for passengers, though.</p>
<p>At the same time, I was running a business (this was before the job offer came along), and I was finding myself slightly uncomfortable delivering rather serious business proposals in a well-used 2003 Jeep. So, I needed something that could fit my young family (my oldest is 2 yrs), and that was presentable to clients. So, I got a Lexus ES350.</p>
<p>I like most things about the car, except for the audio system. It seems schizophrenic to me to have like 6 sound &#8216;zones&#8217; to isolate the audio to certain sets of speakers, but then controls like bass and treble only go from 0 to 5. Huh? And the sound always sounds like it&#8217;s lying on the floor for some reason. It&#8217;s not at all immersive. The sound system on my Jeep completely kicked ass. I miss it. A lot.</p>
<h3>Other News</h3>
<p>I&#8217;ve submitted an article to <a href="http://pythonmagazine.com">Python Magazine</a> about my (relatively) recent work with Django and my (temporarily stalled) overhaul of <a href="http://linuxlaboratory.org">LinuxLaboratory.org</a>, and my experiences with various learning resources related to Django. If you&#8217;re looking to get into Django, it&#8217;s probably a good read.</p>
<p>I&#8217;ve been getting into some areas of Python that were previously dark, dusty corners, so hopefully I&#8217;ll be writing more about Python here, because writing about something helps me to solidify things in my own brain. Short of that, it serves as a future reference point in case it didn&#8217;t get solidified enough <img src='http://www.protocolostomy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>My sister launched<a href="http://thedancejones.com/blog"> The Dance Jones</a>, a blog where she talks about fitness, balance, dance, and stuff I should probably pay much more attention to (I&#8217;m close to declaring war on my gut). Also, if you ever wanted to know how to <a href="http://thedancejones.com/blog/2009/10/19/how-to-shoulder-shimmy/">shoulder shimmy</a> (and who hasn&#8217;t wanted to do that?), you should check it out <img src='http://www.protocolostomy.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.protocolostomy.com/2009/10/22/new-job-car-baby-and-other-news/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Django App Design: Extend or Build From Scratch?</title>
		<link>http://www.protocolostomy.com/2009/08/12/django-app-design-extend-or-build-from-scratch/</link>
		<comments>http://www.protocolostomy.com/2009/08/12/django-app-design-extend-or-build-from-scratch/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 16:21:51 +0000</pubDate>
		<dc:creator>bkjones</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[LinuxLaboratory]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.protocolostomy.com/?p=595</guid>
		<description><![CDATA[Django has proven itself (to me, anyway) as a great tool for the job of creating very robust web applications with lightning speed. In just a week or two, I&#8217;ve created a site that encompasses a blog with an akismet-powered comment moderation system, a code sharing section complete with highlighted code segments (and line numbers), [...]]]></description>
			<content:encoded><![CDATA[<p>Django has proven itself (to me, anyway) as a great tool for the job of creating very robust web applications with lightning speed. In just a week or two, I&#8217;ve created a site that encompasses a blog with an akismet-powered comment moderation system, a code sharing section complete with highlighted code segments (and line numbers), and I have a way to create static HTML pages and map them to whatever URL I want. Behind all of this is an administrative area where I can add/edit/delete any type of content hosted on the site, add users, put them in groups, and even create new sites, and map content to the different sites. It&#8217;s pretty powerful.</p>
<p>One thing I really like about Django is that it lets you be sort of a commitment-phobe, and actually rewards you for it. If you&#8217;re not sure which direction you want to go in with a given feature, just make it as generic as possible. Not sure which URL you want some content to show up at? No problem &#8212; edit a line in the project&#8217;s URLConf, and it&#8217;s somewhere else now. Need to redo that sidebar menu to pull in content from a completely new app? No problem. Edit a template with a couple of new tags, delete some others, and if you&#8217;ve set up inheritance properly, that&#8217;s it. Done. Decided you want users to be logged in to see some content? Multiple ways to do that &#8211; edit the view, edit the template&#8230; easy, easy, easy.</p>
<p>And did I say powerful?</p>
<p>However, with great power, of course, comes great responsibility. One thing I don&#8217;t want to do is create some monstrosity of code with tightly-coupled entities, because that takes away my ability to be non-commital and make on-the-fly changes with the greatest of ease. As it turns out, being non-commital takes a bit of thought, and a bit of work.</p>
<h2>So here&#8217;s the deal&#8230;</h2>
<p>I have a blog app which I think is extremely similar to the blog app in Practical Django Projects, 2nd Edition. It has an Entry object which has some rather nice features that I think are generically useful regardless of whether this &#8220;Entry&#8221; happens to be a blog post, an article in a CMS, a code snippet, or whatever. And this is the root of my design dilemma.</p>
<p>I&#8217;d like to devote a section of my site to republished articles I&#8217;ve written over the years, and new ones I plan to write going forward. Having used Django&#8217;s built-in flatpages app for static HTML content, I can already see that it&#8217;s really not up to doing double-duty as a CMS. Specifically, it doesn&#8217;t have the notion of status, so I can&#8217;t mark something &#8220;Draft&#8221; and come back to it later. It also requires me to put in a URL to create a static mapping between a URL and a flatpage object. Also, flatpage objects don&#8217;t have attributes I&#8217;d like to have like &#8220;Original Publication Date&#8221;, &#8220;Original Publication URL&#8221;, &#8220;Last Updated&#8221;, etc. There&#8217;s no notion of categories, tags, or anything like that, either, which I think could be useful in presenting the list of available articles.</p>
<p>But my blog app has a good bit of that functionality, and my Entry object has a good number of the attributes I want. So where to from here?</p>
<p>Well, I haven&#8217;t looked deeply into this, but I know I could subclass Entry, make the one or two changes I&#8217;d need, and go that route. Unfortunately, doing this basically means that the CMS isn&#8217;t really &#8220;standalone&#8221;. It depends on my blog app.</p>
<p>The other option is to build the features I want *into* the blog app itself. I haven&#8217;t looked deeply into this either, but I don&#8217;t think it would be all that difficult to create a way for me to specify at the time I create an &#8220;Entry&#8221; that this piece of content is a &#8220;Blog Post&#8221; or an &#8220;Article&#8221;. However, at that point I&#8217;m basically turning my standalone blog app into something that is not just a blog app. If I ever built another site and only wanted a blog, I couldn&#8217;t just move my blog app into place and have it. Or&#8230; I could, but I&#8217;d have all this &#8220;Article&#8221; cruft hanging around in my admin interface.</p>
<p>This is all not to mention that I&#8217;d be breaking a tradition of keeping things small and simple, both to ease debugging, and to ease future development of the small, simple app. Everything becomes more complex. Maybe I&#8217;m answering my own question&#8230;</p>
<h2>What to do?</h2>
<p>I&#8217;m unsure which way to take it, to be honest. My thinking right now is that I&#8217;ll just copy my blog app&#8217;s models.py file to my new app, make my changes there in the new app, and &#8216;syncdb&#8217;. Sure, it&#8217;s redundant&#8230; but it&#8217;s only redundant *today*. If I decide later on to add a feature to the blog that makes absolutely no sense for the CMS (or vice versa), I win. If I decide to create a new site that only needs a CMS *or* a blog, I also win.</p>
<p>I&#8217;m always open to suggestions and bits of wisdom from folks who&#8217;ve been down this road before. If you see big gaping flaws in my logic, let me know. Otherwise, I&#8217;m gonna create some short-term redundancy in exchange for some long-term flexibility.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.protocolostomy.com/2009/08/12/django-app-design-extend-or-build-from-scratch/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Create a Tagging Index Page with django-tagging</title>
		<link>http://www.protocolostomy.com/2009/08/11/create-a-tagging-index-page-with-django-tagging/</link>
		<comments>http://www.protocolostomy.com/2009/08/11/create-a-tagging-index-page-with-django-tagging/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 03:11:41 +0000</pubDate>
		<dc:creator>bkjones</dc:creator>
				<category><![CDATA[Big Ideas]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[LinuxLaboratory]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.protocolostomy.com/?p=593</guid>
		<description><![CDATA[For those not following along, I&#8217;ve been recreating LinuxLaboratory.org using Django. It&#8217;s my first Django project that you could call &#8220;real work&#8221;. I&#8217;ve been using the Django documentation, various blogs, and the 2nd edition of &#8220;Practical Django Projects&#8221;, which has given me a lot of ideas, and a lot of actual code. Some of it [...]]]></description>
			<content:encoded><![CDATA[<p>For those not following along, I&#8217;ve been recreating LinuxLaboratory.org using Django. It&#8217;s my first Django project that you could call &#8220;real work&#8221;. I&#8217;ve been using the <a href="http://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-tags">Django documentation</a>, various blogs, and the 2nd edition of &#8220;Practical Django Projects&#8221;, which has given me a lot of ideas, and a lot of actual code. Some of it worked, some of it didn&#8217;t, some of it didn&#8217;t do things the way I wanted, and some of it was left as an exercise to the user. This was the case with some of the django-tagging-related stuff, which has been broken on the site for a while.</p>
<p>I finally got tired of tagging not working properly on LinuxLaboratory.org, so I started diving into the code and found that one of the things I wanted to do was actually pretty darn easy. In the process, I thought of something else I&#8217;ll probably implement later as well. Not *all* of my problems are solved, but I&#8217;m on my way!</p>
<p>So, Linuxlaboratory is made up of three different sections: a blog, which is its own app, a &#8220;Code&#8221; area which is another separate app, and a content management system (flatpages right now) that will handle storing republished articles when I get around to importing them all.</p>
<p>I enabled tagging on everything. I&#8217;m not solidly in one camp or the other on the whole &#8220;Tagging everything is bad&#8221; debate. Rather than theorize, I decided to give it a go and see how it does. My guess is that once I add a search box it will rarely actually be used, but what do I know?</p>
<p>The problem this presented me with was trying to figure out a way to present the user with one big monstrosity of an &#8220;index lookup&#8221; page, which would list all of the tags, and for each tag, list links to anything of any content type that was tagged with it. I understand that this could become unwieldy at some point, but if I need to I suppose I can pretty easily paginate, or present alphabet links, or perhaps both!</p>
<p>Though I understood the potential for future disaster, it still bothered me that I couldn&#8217;t find a quick answer to the question, so here it is for those wanting to do something similar with django-tagging. For reference, my tag index page is <a href="http://linuxlaboratory.org/weblog/tags/">here</a>.</p>
<h2>Template Tags in django-tagging</h2>
<p>I had actually started creating a custom template tag, and was looking at the Django docs, which stated &#8220;a lot of apps supply custom template tags&#8221;. Duh! I cd&#8217;d into the tagging directory, and there was a directory called &#8220;templatetags&#8221;. The tagging_tags.py file inside was pretty well documented, and the tag I was about to write myself is called &#8216;tagged_objects&#8217;. Here&#8217;s the docstring for that tag:</p>
<blockquote><p>&#8220;&#8221;"<br />
Retrieves a list of instances of a given model which are tagged with<br />
a given &#8220;Tag&#8220; and stores them in a context variable.</p>
<p>Usage::</p>
<p>{% tagged_objects [tag] in [model] as [varname] %}</p>
<p>The model is specified in &#8220;[appname].[modelname]&#8220; format.</p>
<p>The tag must be an instance of a &#8220;Tag&#8220;, not the name of a tag.</p>
<p>Example::</p>
<p>{% tagged_objects comedy_tag in tv.Show as comedies %}</p>
<p>&#8220;&#8221;"</p></blockquote>
<p>Perfect. I already had a tag_list.html template (which, if memory serves, is one of the things left as an exercise to the user in Practical Django Projects), and it listed the tags in use on the site, but instead of linking off to a &#8216;tag_detail&#8217; page for each tag, I envisioned something more interesting. I&#8217;m not there yet, but this index page is step one.</p>
<h2>Putting Together a Template</h2>
<p>What I needed to do was simply {% load tagging_tags %}, and then call the {% tagged_objects %} tag with the proper arguments, which consist of a tag *object* (not a tag name), the model you want to grab instances of, and a variable name you want to store the instance in. Here&#8217;s the content block from my tag_list.html:</p>
<pre>{% block content %}
{% for tag in object_list %}
&lt;div id="entry"&gt;
   &lt;p&gt;{{ tag.name }}&lt;/p&gt;
   &lt;ul&gt;   {% load tagging_tags %}
      {% tagged_objects tag in  monk.Entry as taggedentries %}
      {% for entry in taggedentries %}
         &lt;li&gt;&lt;a href="{{ entry.get_absolute_url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
      {% tagged_objects tag in ray.Snippet as taggedsnippets %}
      {% for snippet in taggedsnippets %}
         &lt;li&gt;&lt;a href="{{ snippet.get_absolute_url }}"&gt;{{snippet.title}}&lt;/a&gt;&lt;/li&gt;
      {% endfor %}
   &lt;/ul&gt;
&lt;/div&gt;
{% endfor %}
{% endblock %}
</pre>
<p>So, the view I&#8217;m using supplies Tag objects in a variable called object_list. For each Tag object, I spit out the name of the tag. Underneath that on the page, for each tag, there&#8217;s an unordered list. The list items are the Entries from my &#8220;monk&#8221; application, and my Snippets from my &#8220;ray&#8221; application. I hope reading this template along with the bit above from the docstring for the template tag helps someone out. And check out the other tags in tagging_tags.py as well!</p>
<h2>Rome Wasn&#8217;t Built in a Day</h2>
<p>Of course, there&#8217;s still an issue with my particular implementation. Tagging was originally implemented specifically for the entries in the &#8220;/weblog/&#8221; part of my site. However, now that they&#8217;ve been applied to things in the &#8220;/snippets/&#8221; part of my site, this page doesn&#8217;t *really* belong in either one. However, if you <a href="http://linuxlaboratory.org/weblog/tags/" target="_blank">go to the page</a>, you&#8217;ll see that the &#8220;Blog&#8221; tab in the navigation bar is still highlighted. I&#8217;ll figure out what to do with that at some point. Until then, enjoy, and if you have any input or wisdom to share, please leave comments! Also, you should <a href="http://twitter.com/bkjones">follow me on twitter</a>!</p>
<pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.protocolostomy.com/2009/08/11/create-a-tagging-index-page-with-django-tagging/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My Django Project Update: RSS Feed, &#8220;Home&#8221; Link, and more.</title>
		<link>http://www.protocolostomy.com/2009/08/10/my-django-project-update-rss-feed-home-link-and-more/</link>
		<comments>http://www.protocolostomy.com/2009/08/10/my-django-project-update-rss-feed-home-link-and-more/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 03:55:05 +0000</pubDate>
		<dc:creator>bkjones</dc:creator>
				<category><![CDATA[Big Ideas]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[LinuxLaboratory]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.protocolostomy.com/?p=586</guid>
		<description><![CDATA[In continuing the rebuild of LinuxLaboratory.org using Django, I&#8217;m happy to say that things have moved fairly smoothly. I&#8217;m using a good mix at this point of stuff from the 2nd edition of &#8220;Practical Django Projects&#8221;, the Django documentation, blog posts, and docs from other apps I&#8217;m making use of. RSS I said in one [...]]]></description>
			<content:encoded><![CDATA[<p>In continuing the rebuild of LinuxLaboratory.org using Django, I&#8217;m happy to say that things have moved fairly smoothly. I&#8217;m using a good mix at this point of stuff from the 2nd edition of &#8220;Practical Django Projects&#8221;, the Django documentation, blog posts, and docs from other apps I&#8217;m making use of.</p>
<h2>RSS</h2>
<p>I said in one of my previous posts that I&#8217;d wait until I burned my feed before giving out the link, and I just did that, so if you want to subscribe to the LinuxLaboratory Blog feed, <a href="http://feeds.feedburner.com/linlab" target="_blank">here&#8217;s the link to do that</a>. Right now there&#8217;s just one feed for all of the blog entries, but since I post almost all of my really geeky stuff here, the LLO Blog will be mostly site updates like new articles, code, or features being added. The LLO Blog isn&#8217;t something that&#8217;s intended to get tons of traffic or have tons of posts all the time. The meat of the site will be the content management system which houses articles, and the &#8220;Snippets&#8221; area which will house scripts and hacks and stuff.</p>
<h2>The &#8220;Home&#8221; Link in Django</h2>
<p>I&#8217;m not sure why, but it took me a little time to figure out how to link to the base site in a Django template. I had some URL routing set up such that, well&#8230; here&#8217;s what I have:</p>
<p>In the main project&#8217;s urls.py:</p>
<pre>(r'^$', include('monk.urls.entries'))
</pre>
<p>I named my blog app &#8220;monk&#8221;, after Thelonius Monk. There&#8217;s actually a reason I picked his name for a blog app, but it&#8217;s not important right now (though, for a chuckle, I picked his last name because his first name breaks a long-standing &#8220;8 character&#8221; tradition in UNIX).</p>
<p>Anyway, in the corresponding URLConf in monk, I have:</p>
<pre>(r'^$', 'archive_index', entry_latest_dict, 'monk_entry_archive_index')
</pre>
<p>And then in one of my base templates I had this (which is perfectly valid code):</p>
<pre>&lt;a href="{% url 'monk_entry_archive_index'}"&gt;LinuxLaboratory.org&lt;/a&gt;
</pre>
<p>The &#8216;{% url %}&#8217; tag can take a URLConf name as an argument, and it&#8217;ll do a reverse lookup to get the URL, which is nice, except that this would always land people at &#8220;http://linuxlaboratory.org/weblog&#8221;, and I wanted them to just go to the base URL for the site. The canonical home page. The root URL. Whatever you want to call it.</p>
<p>There are multiple ways to link back to the base domain from within a template, but I&#8217;m not sure if there&#8217;s a canonical, &#8220;Django-sanctioned&#8221; method. You can just make an href pointing to &#8220;/&#8221;, you can hard-code the whole URL, and I found that doing &#8220;href={{ settings.SITE_ID }}&#8221; also worked just fine. I tried that last one after discovering that the base URL for the site isn&#8217;t in settings.py, and reading that SITE_ID was used by some applications to help them figure out their own URL routing. SITE_ID is a numeric value that represents, according to the Django docs, &#8220;the current site in the <tt><span>django_site</span></tt> database table&#8221;.</p>
<p>That&#8217;s a little confusing, but if you just have a look at the table, it starts to become clear how this <em>could</em> work:</p>
<pre>mysql&gt; select * from django_site;
+----+---------------------+---------------------+
| id | domain              | name                |
+----+---------------------+---------------------+
|  1 | linuxlaboratory.org | linuxlaboratory.org |
+----+---------------------+---------------------+
</pre>
<p>It seems logical that using {{ settings.SITE_ID }} in a template could cause the right things to happen, but I haven&#8217;t gone diving into the source code I&#8217;d need to to prove that it does.</p>
<p>What&#8217;s the canonical way of doing this?</p>
<h2>Up Next&#8230;</h2>
<p>So, I have what I think will be a decent setup for code sharing (complete with highlighted syntax), a solid foundation for a blog app, and I&#8217;m working on the content management system. I&#8217;m using TinyMCE in the admin interface to edit blog posts as well as the CMS content. I&#8217;ve got very very basic CSS in place. The basics are here. Now what?</p>
<p>Well, first I need to get my ducks in a row. This includes:</p>
<ul>
<li>Stabilizing a proper development and deployment workflow. There&#8217;s a rather nice setup <a href="http://blog.haydon.id.au/2009/07/django-development-workflow.html">over here</a>, and the 2nd edition of Practical Django Projects has also been enlightening in this regard.</li>
<li>Cleaning up my templates. I created the Blog app first, and so of course now I have like 3 separate apps, and I don&#8217;t really want them all to have a different look and feel, so I need to abstract some bits and perhaps create a &#8220;/templates/common/&#8221; directory that will be referenced by all of the apps in the project&#8230;? How do you do it?</li>
<li>I&#8217;d like to get some high-level navigation horizontally across the top instead of having those links in the sidebar. I don&#8217;t want fancy popout menus &#8212; just a very simple bar where the nav links basically just represent the functions of the different apps: Blog, Articles (CMS), Code, and maybe an About link or something.</li>
<li>And more!!</li>
</ul>
<p>After that stuff is out of the way I&#8217;ll start thinking about some new features:</p>
<ul>
<li>I&#8217;d like to be able to include images (maybe multiple images) in various types of content. In fact, perhaps all kinds of content. Screenshots for the code snippets, stock images for CMS and blog content, etc. I&#8217;m a little intimidated by this because I know my web host (webfaction) limits the amount of memory I can use at any given time. I guess I can just manually scp images to my static media location and link them into the content, but it doesn&#8217;t seem ideal. Ideally I can upload them in the same interface where I edit the content, and maybe have the img src tag associated with the instance of the model I&#8217;m editing in the database. Does something do this already?</li>
<li>I&#8217;d really like to have a wordpress-style &#8220;Stats&#8221; page. Actually, I&#8217;d like to have a much better stats page than the wordpress one, but that&#8217;d be a start. The stats page I&#8217;d actually *like* to have is best described by Marty Allchin <a href="http://martyalchin.com/2007/nov/16/data-visualization-in-django-dream/" target="_blank">here</a> (2 years ago. Anyone know of an app that is aiming for anything close to that?)</li>
<li>RSS feeds for the code snippets section (this should be simple)</li>
<li>On-the-fly PDF generation for downloading the PDF version of&#8230; whatever. A code snippet, an article&#8230; Haven&#8217;t even investigated this yet.</li>
<li>I really, really, really, really want to turn my <a href="http://www.protocolostomy.com/2008/12/23/holiday-project-plot-google-calendar-events-on-google-map/">geek conference calendar into a google maps mashup</a> using GeoDjango. This is another bit I&#8217;m slightly intimidated by, because I didn&#8217;t realize GeoDjango was built-in these days, and I started out down this road using MySQL as my database for whatever reason (instead of PostgreSQL, which I actually like better and, as it turns out, has way more mature GIS functionality).</li>
<li>At some point, I&#8217;d like to ensure that the old URLs to content that was on the old site will actually still work, and land people on the same content in the new site. The URL layout isn&#8217;t actually horrifically different, so hopefully I can get that in place without *too* much fuss. I know Django has a redirection app built-in, but I&#8217;m not sure if this is the right way to do it, or if I should just use Apache rewrite rules. Anyone compared the two?</li>
</ul>
<p>So those are the big goals. Some are simple, others less so, but I hope to complete all of this within the next&#8230; well, before the new baby is born, which is going to be some time in the first half of September. Wish me luck (on both), and please share your tips on how I might accomplish any of the above goals (I&#8217;ve heard all the tips I can handle about kids, thanks).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.protocolostomy.com/2009/08/10/my-django-project-update-rss-feed-home-link-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django, Pygments, Templates, Code Sharing, and Design</title>
		<link>http://www.protocolostomy.com/2009/08/09/django-pygments-templates-code-sharing-and-design/</link>
		<comments>http://www.protocolostomy.com/2009/08/09/django-pygments-templates-code-sharing-and-design/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 21:01:28 +0000</pubDate>
		<dc:creator>bkjones</dc:creator>
				<category><![CDATA[Big Ideas]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[LinuxLaboratory]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.protocolostomy.com/?p=583</guid>
		<description><![CDATA[Welcome to the latest update! I spent a total of about an hour on the &#8220;Social Code Sharing&#8221; application in the 2nd edition of &#8220;Practical Django Projects&#8221;, and I&#8217;m not completely finished with it, but I&#8217;ve got syntax highlighting and the basics covered. I can add, edit, and delete snippets, list snippets, and show a [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to the latest update!</p>
<p>I spent a total of about an hour on the &#8220;Social Code Sharing&#8221; application in the 2nd edition of &#8220;Practical Django Projects&#8221;, and I&#8217;m not completely finished with it, but I&#8217;ve got syntax highlighting and the basics covered. I can add, edit, and delete snippets, list snippets, and show a particular snippet, complete with syntax highlighting. In an hour. That&#8217;s pretty ok, considering I spent a lot of that time debugging what I would call, at best, an unexplained inconsistency in the book that caused me to run into a series of errors before finally figuring out the right way to do it (it&#8217;ll all be in the book review &#8211; stay tuned for that).</p>
<p>I don&#8217;t have links or user contribution set up yet. I only have a quick example up right now, which you can see <a href="http://linuxlaboratory.org/snippets/1/" target="_blank">here</a>, which brings me to the design question: I want my navigation sidebar on the right, but I really don&#8217;t want the code to overlap it in any way. I&#8217;m kinda wondering if there&#8217;s an elegant way to fix that. I considered moving the sidebar to the left, but didn&#8217;t want to do that. I considered just making the main content area bigger, but then I&#8217;m just guessing, and praying that it fixes the problem for all future code snippets. What&#8217;s there now is just a CSS-based solution that creates a scrollable area for the code if it&#8217;s too long. Maybe this will suffice (though I have some CSSing to do to refine what&#8217;s currently there &#8212; the entire content area scrolls right now!)</p>
<p>Since there&#8217;s no example template for dealing with code highlighting in the book, and the downloadable code only goes through the first app in the book (the CMS app), here&#8217;s the template I&#8217;m using for the snippet_detail.hml file:</p>
<pre>{% block title %}{{block.super}} | Random hacks{% endblock %}
{% block extrahead %}
&lt;link rel="stylesheet" type="text/css" href="/static_media/llo_main/css/pygments.css" /&gt;
{% endblock %}
{% block content %}

 &lt;ul&gt;
 &lt;li&gt;{{ object.title }}&lt;/li&gt;
 &lt;li&gt;Published: {{ object.pub_date }} Updated: {{ object.updated_date }}&lt;/li&gt;
 &lt;li&gt;Language: {{ object.language }}&lt;/li&gt;
 &lt;li&gt;Author: {{ object.author }}&lt;/li&gt;
{% load markup %}
 &lt;li&gt;Description: {{ object.description_html|markdown }}&lt;/li&gt;
 &lt;/ul&gt;

&lt;p&gt;
{{ object.highlighted_code|markdown }}
{% endblock %}
</pre>
<p>Your CSS path will be different, in all likelihood, and there are some touches missing, like use of a variable to make the title bar dynamic and stuff, but right now I&#8217;m shooting for function &#8212; the form will come later.</p>
<p>For the snippet_list.html file, I found that what&#8217;s in the book just doesn&#8217;t work at all. It uses pagination using Django&#8217;s built-in pagination capabilities, but the small subset of a template that&#8217;s provided references a {{ page }} variable, which does nothing. The Paginator class appears to make individual pages available to templates in a variable you&#8217;d reference as {{ page_obj }}, not {{ page }}. Referencing {{ page_obj }} by itself (without referencing any attribute of it) results in output that says something like &#8220;&lt;Page 1 of 1&gt;&#8221;.</p>
<p>It&#8217;s not necessarily pretty to have those &#8220;&lt; &gt;&#8221; around the edges of the output, and it&#8217;s not necessary to use this method of getting the page number and the page count. The page number is available as an attribute of the page class, and the total number of pages is available from the associated paginator object&#8217;s &#8216;num_pages&#8217; method, which you can grab via {{ page_obj.paginator.num_pages }}. You can see my snippets_list.html output <a href="http://linuxlaboratory.org/snippets/" target="_blank">here</a>, and here&#8217;s my template (at time of writing &#8211; note that my site is a work in progress and can change without warning):</p>
<pre>{% block content %}

&lt;p&gt;Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}&lt;/p&gt;
&lt;p&gt;
{% if page_obj.has_previous %}
&lt;a href="?page={{page_obj.previous_page_number}}"&gt;Previous page&lt;/a&gt;
{% endif %}
{% if page_obj.has_next_page %}
&lt;a href="?page={{ page_obj.next_page_number }}"&gt;Next page&lt;/a&gt;
{% endif %}&lt;/p&gt;

{% for snippet in object_list %}
 &lt;ul&gt;
 &lt;li&gt;&lt;a href="{{snippet.get_absolute_url}}"&gt;Title: {{ snippet.title }}&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;Published: {{ snippet.pub_date }} Updated: {{ snippet.updated_date }}&lt;/li&gt;
 &lt;li&gt;Language: {{ snippet.language }}&lt;/li&gt;
 &lt;li&gt;Author: {{ snippet.author }}&lt;/li&gt;
 &lt;li&gt;Description: {{ snippet.description_html }}&lt;/li&gt;
 &lt;/ul&gt;
{% endfor %}

{% endblock %}
</pre>
<p>In the interest of full disclosure, I should also say that, at time of writing, I haven&#8217;t added enough snippets to fully test the previous and next page links. I&#8217;ll get there, I&#8217;m sure &#8212; especially when I get user contributions in place, which will happen when I feel a little more confident that this is going to happen in a secure manner. Having been to PHP land, it&#8217;s a little unnatural for me to trust the code that comes with a framework to do things properly, which my sysadmin brain always parses as &#8220;securely, and in a functionally correct manner&#8221;.</p>
<p>Please share tips in the comments! That&#8217;s the update for now &#8212; stay tuned for more as the recreation of LinuxLaboratory.org continues to unfold.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.protocolostomy.com/2009/08/09/django-pygments-templates-code-sharing-and-design/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

