Current Twitter Status

See status in context

Subsidized Fear

Terror Alert Level

Into The Past »

Blog Entries Tagged With “django” (Show All Items Tagged With “django”)

October Braindump

Posted on Thursday, October 22, 2009 @ 06:34 CDT by Daniel Andrlik

I have not been posting here much of late, which is partly due to the amount of stuff I’m working on, and partly due to the fact that I’ve been writing and posting stuff in other places around the web, since it is easier. Some of this will get fixed with the next revision of this site, but honestly, it has less to do with those other things I’m working on and a lot more to do with general laziness. Either way, it is high time for an update.

What have I been doing?

Among other things, I’ve been working on the next version of the custom CMS that powers this site. I initially started this process to fix the comment issue I was having, and it quickly turned into a complete rewrite of the Django applications I use to power Andrlik.org. It’s a lot of work, mostly because I started off with way too large of feature list. I would trim some of those features, but at this point the actual code for the new stuff is already written. Ironically, it is the new comment application (among a few other things like actual template design) that are not completed yet.

The new site is being rewritten from the ground up to take advantage of all the new features and capabilities available in Django trunk, and it will incorporate pulling detailed activity data from virtually every social network I participate in that provides an API. I have not decided to what extent this information will play a role in the actual layout of this site, the primary purpose of these features is to provide me with an automated backup of all of that data. In addition to pulling data from social networks, I’m adding more discrete media types to the site which should allow me to do more interesting things such as podcasts if it ever strikes my fancy to do so. There is some basic podcast support baked into the blog application for the current site, but it’s inelegant and a pain to use.

In addition to new features for me, I’m incorporating the ability for readers to authenticate using OpenID, Facebook, or Google, the latter two options being new, while improving compatibility of my OpenID solution. I’m doing this because I’m planning to allow comments from authenticated users only, which allows me to utilize different privacy settings for any posts.

So, yeah, that should be cool. At least, whenever I get around to finishing it and deploying the new version to the server. :-)

I’ve also been busy with work, and doing a lot of traveling, which means by the time I get back to the hotel room I am ready to pass out. When at home, I’ve been reading, spending quality time with my girlfriend, and working on yet another project that I can’t talk about yet.

Splattered Content

While I have not been posting or bookmarking here, I have been posting to various other sites online. Of course, there is always my Twitter feed, where I post random bits of questionable wit, as well as links to stories I find interesting. In addition, as I’ve been reading, I’ve been posting quite a few book reviews to my Goodreads account, which I try to also mirror on my Readernaut profile, when possible. In general, I don’t include rereading books in my activity streams but there has certainly been a lot of that going on as well.

Every time I post a review to either service, I feel like I should expand it out into a real post for this site, but I rarely take the time to, which is a habit I hope to change in the upcoming months. In the meantime, I thought I would include some of my Goodreads reviews for books I’ve recently read that are particularly notable.

Memories of the Future, Part 1 by Wil Wheaton: 4 out of 5 stars

I really enjoyed this book. I laughed so much while reading Memories of the Future, more than I have for any other book in recent memory.

The episode recaps are the real stars of the book, and I would often stop to read a particularly hilarious passage out loud to my girlfriend. However, this isn’t just a book of condensed snark; Wheaton’s love of Star Trek TNG comes through on every page. His profound respect for his fellow actors, and his affection for what the show will become gives the recaps a humane quality. As a result, the snarky episode recaps, feel less like a nasty internet posting (the natural habitat of undiluted snark), and more like the playful ribbing of a friend at the dinner table, while reminiscing about that embarrassing event that everyone had to go through back in high school.

It’s a great book, but I do have a tiny niggling complaint. There’s a lot of references in the recaps to later episodes by their title, which I wouldn’t mind if the recaps of those episodes were in the same volume, however a few of them are slated for volume two, and since I don’t have the 1st season of TNG around the house to figure out what Wheaton’s referring to, I felt left out of a joke that probably won’t make sense to me until the second volume comes out (soon, I hope).

There were also a couple episodes where Wheaton didn’t actually recall anything from behind the scenes, so for those entries the “Behind the Scenes Memory” section would be a little weak.

To sum up: I loved this book and can’t wait for volume two. However, I knock off one star for the two small complaints I mention because I am a bit of a prick despite Wil Wheaton’s sage advice: “Don’t be a dick!”

Old Man’s War by John Scalzi: 3 out of 5 stars.

I enjoyed this book, which actually surprised me a bit. Typically with sci-fi I tend to prefer heavier fare, but Scalzi’s light touch with his prose worked for me quite well. It’s central idea is spectacular story-fodder, and I’m interested in seeing what he does with it in the later books of the series.

Unfortunately, there is a little bit of a strange disconnect in the story, which might have a lot to do with the fact that the protagonist seems to excel at everything, and never seems to face a real challenges, so the central conflict of the story feels almost superficial. Also, the alien species are painted in very broad strokes, and it gave me the impression (rightly or wrongly) that the universe was not fully realized by the author beyond the limited conflicts that are depicted. That’s not necessarily a bad thing, but I like to feel a bit more depth to the world, and I might have been able to ignore it had the protagonist faced more challenges.

Don’t ge me wrong, I enjoyed the book, and will try out the next book in the series, but the disconnection I felt means I can only give it three stars.

Boneshaker by Cherie Priest: 4 out of 5 stars

This was my first experience with Priest’s work, and it was a pleasure. I found it to be a brilliantly imagined steampunk novel set during an extended Civil War, and in Seattle, a catastrophic event has brought the Blight upon the city, which causes the dead to walk. The story focuses on a mother seeking to save her son, whom has charged off into the city to find out about his father. Along the way she encounters air pirates, zombie rotters, and the other people who choose to brave the Blight, living beneath the ground and in sealed vaults for protection. However, it’s also a mystery, for the son’s quest will lead them both on a journey to answer the questions raised by the Blight, and to learn once and for all the real history of the experiment that brought the plague.

The book is well written, the action is tight, and it’s just a hell of a lot of fun to read. The only complaint I have is that the last chapter seemed a little flat to me, almost an unnecessary epilogue, that answers none of the questions that still remain, but without actually building any sort of wonderment or cliffhanger. This is the reason that I’m only giving it four stars.

The Child Thief: A Novel by Brom: 4 out of 5 stars

I admit that I approached this book with trepidation. In the past, I have encountered a number of attempts to retell the Peter Pan story, most of them spectacularly bad. Add in the fact that the author only goes by a single name, and alarm bells begin to ring.

I was pleasantly surprised. What I found was a dark, tense and well written piece of fiction that successfully reinvents Peter Pan, while still holding true to the core elements of the original. Brom doesn’t cheat. Peter is an unpredictable and violent figure, who is clearly borderline insane. However, Brom also demonstrates quite clearly that Peter is a pawn of greater forces, and the enemy that he is being pitted against is truly horrifying. With this in mind, you might almost forgive him for stealing the abused children of the world in order to serve as infantry in the battle, but the author rightly refuses to let Peter off that easy. You are confronted with the terror the children feel, and that is what makes this novel work.

And if that wasn’t enough, it comes in a beautiful hardcover edition with artwork from the artist himself. It’s definitely worth a read, so if you hear the same alarm bells I did, cover you ears. This book is worth it.

I’d also add in that you should read all of the Joe Abercrombie books in First Law trilogy, including the one-shot follow-up novel Best Served Cold. However, I recommend you start with the trilogy, and I am including my review of the first book. It is worth noting that the first book of the trilogy is the only one that I awarded less than five stars.

The Blade Itself by Joe Abercrombie: 4 out of 5 stars

An outstanding debut novel and start to a trilogy. Abercrombie does a wonderful job of introducing all of the complex characters and manages to make them all fascinating in their own right, although every reader may favor some more than others. In my case, I am particularly captivated by both Logan, the practical barbarian that is haunted with regret, and Glotka, the crippled torturer and inquisitor.

Abercrombie is also very effective at introducing the reader to his world, without much tedious exposition, which is a welcome change from a lot of other epic-fantasy. He also clearly illustrates what is at stake and carefully sets the events in motion that one assumes will drive the course of the story in the next two books.

I do have one complaint, and that is that occasionally Abercrombie starts a chapter without clearly telling you which character’s point of view the narrative is being told through, which can be a bit confusing. Usually, you can tell just from the voice of text, which is quite an accomplishment on the author’s part, but occasionally I would encounter a chapter and it would take me half a page to orient myself, which is the only reason I’m knocking off one star.

I can easily seeing this book joining the likes of Martin’s A Song of Ice and Fire and Rothfuss’s Kingkiller Chronicles as one of my favorite epic fantasy series produced recently, and I can’t wait to start on the next book in The First Law series.

Needless, to say I loved the rest of that series.

Get Back To Work

I’m serious, I’m sure we all have shit to do. I’m sure the various things I am working on will keep me busy over the next few months, but I will try to post here more often so that I don’t have to do such a gigantic braindump next time.

Code Revision and NaNoWriMo

Posted on Saturday, October 18, 2008 @ 18:35 CDT by Daniel Andrlik

I have not had time to post here in a while. My new job has kept me very busy and most of the time when I get home I just want to relax and spend time with my girlfriend. It is a little frustrating that I have fallen behind on personal projects (like this site), but the work is fulfilling so that is OK.

All that being said, it really nags at me. I haven’t had a chance to bring comments back online here yet, primarily because I realized that before I do that I should probably update the code of this site for Django 1.0 which was recently released. This site is currently running off of Django trunk, unfortunately in the midst of moving and switching jobs I’m several months behind and there are some major revisions that occurred during that time. It won’t be a trivial task, so I wouldn’t expect it to get done right away. So comments will continue to be disabled until the rewrite is done. You are always welcome to contact me, or comment on FriendFeed in the meantime.

The other reason that the rewrite is going to be delayed is that I’ve decided to participate in NaNoWriMo this year. This is actually going to be a serious challenge because it looks like November is already going to be a busy month for me and squeezing out 50,000 words at the same time is going to be rough. However, my right brain is feeling lonely and coding projects just aren’t satisfying my urge to do something creative. I don’t really want to get into a debate of the merits of people cranking out a word count during a month rather than focusing on writing really well. That’s a subject for another time. The way I’m looking at NaNoWriMo is that it’s a kick in the ass for me to get my act together, stop talking about writing, and just write.

I’ve actually attempted NaNoWriMo once before, but I kept it a secret at the time because I was afraid of publicly failing to meet the goal. Consequently, I used that as an out to procrastinate and not get anything done beyond the first few pages. Deadlines don’t matter if there is no consequence for failing to meet them, and I don’t want to fall into that trap again. This year, I plan to be very open and public about how I’m doing during NaNoWriMo, both by posting to the official NaNoWriMo site, as well as posting here and on Twitter. I’ll try to provide an update once a week here, and Twitter posts will appear with the same level of randomness they always do.

If you haven’t ever participated in National Novel Writing Month and you have the urge to write, but can’t seem to bring yourself to get it done, consider signing up this year. Post how you are doing online, and we can go on this journey together. Maybe we succeed, maybe we don’t, but we’ll learn a lot about ourselves as writers in the meantime.

Quick Post: My Pownces, Let Me Show You Them

Posted on Wednesday, March 5, 2008 @ 17:12 CST by Daniel Andrlik

Heh, I had a little fun this afternoon writing a little Django app for my site that will regularly import my public Pownce notes and allow me to display them in the sidebar. It’s really just a modified version of the app I’m using for my Twitter statuses, except that it has some additional logic for handling the different types of Pownce notes.

The thing I’m most happy about is that if I post a public Pownce event, it will display the event with the appropriate microformat markup. Events also include a link to a Google Map of the location, as well as a link to an iCal file for the event. Those last two are provided for free by the Pownce API, so it just seemed to make sense to use them.

Eventually, the look will get redesigned as I redo this site’s design, but for now I’m pleased with it.

Happy Powncing!

Yaaar

Posted on Wednesday, September 19, 2007 @ 00:05 CDT by Daniel Andrlik

Ahoy, mateys! Today be the official Talk Like A Pirate Day and the Ministry o’ Intrigue will be celebrating by servin’ up all me text as pirate speak fer the duration.

This be accomplished by activatin’ a piece o’ Django middleware as suggested in thar Django Master Class and I be using the pirate filter ported to Python by the swashbucklin’ Jacob Kaplan-Moss.

So go and celebrate proper or ye’ll be keelhauled or at least made to walk the plank!

UPDATE: Well that was fun. :-) Now the holiday is over, so I’m turning the middleware off.

Fun With Django Feeds

Posted on Friday, August 3, 2007 @ 02:04 CDT by Daniel Andrlik

I would like to take a moment to show you how easy it is to create feeds in Django, and the easiest way to do that is by example. For brevity’s sake, I’m going to use a simplified version of a Django-powered blog. So, let’s say you have a simple blog, where posts consist of a title, slug, pub_date, body and some tags. So your model would look something like this:

blog/models.py

from django.db import models
from tag.fields import TagField
from datetime import datetime

class Entry(models.Model):
    title = models.CharField(maxlength=250)
    slug = models.SlugField(
                 maxlength=250,
                 prepopulate_from=('title'),
                 unique_for_date='pub_date'
    )
    body = models.TextField()
    pub_date = models.DateTimeField(default=datetime.now())
    is_draft = models.BooleanField(default=True)
    allow_comments = models.BooleanField(default=True)
    tags = TagField()
    
    def __unicode__(self):
        return self.title
    
    def get_absolute_url(self):
        #You would fill this in here and call it when you need it or 
        #use the permalink decorator
        #Regardless, you want to customize it for your urls.py
        pass

Now, I’m assuming you already know something about the Django ORM, but I’ll summarize for those of you that don’t. Essentially, we are creating an object of type Entry, which represents a table in your database and has the attributes I listed above. I’ve added a few constraints, such as requiring the slug field to be unique for a given date, since in most cases you will probably build a permalink along the lines of /year/month/day/slug. I’ve also cheated and added two boolean fields which designate if the entry is a draft, and if it allows comments, because they are too useful to leave out, even in an example. TagField is supplied by the django-tagging app, and doesn’t really affect the rest of this example, but I love it so I’m going to leave it in. ;-)

Okay, so you’ve got your model and you have used it to load up some entries, and now it suddenly occurs to you: What’s a blog without a subscription feed? The answer to that question is: Probably not worth the effort to remember visiting on a regular basis. You need an RSS feed! Luckily for you, Django makes this dead simple.

So, the first order of business is to define a feed class to represent your data. Unless you have very complex needs, this is very simple because you just have to subclass the Feed class in Django. You’ll have to define a few variables and then tell the feed what items it should be displaying and what date is the representative pubdate. So, a simple example might look like this:

feeds.py

from django.contrib.syndication.feeds import Feed
from blog.models import Entry

class BlogFeed(Feed):
    '''Feed for latest 15 blog entries'''
    #These could also be pulled from your settings.py file to avoid repetitive hardcoding
    title='My Blog'
    link='http://www.example.com' #URI of site
    description='Latest Blog Entries'
    
    item_author_name='Joe Blow'
    item_author_email='joe@example.com'
    item_author_link='http://www.example.com' #URI of author
    
    def items(self):
        #What items to use in the feed
        return Entry.objects.filter(is_draft=False).order_by('-pub_date')[:15]
    
    def item_pubdate(self,item):
        #For each item, what is the pubdate?
        return item.pub_date

So, that’s a simple feed. Now you need to assign this feed to a url, which you do by adding it to your urls.py file. I’m going to just include the feed urls line rather than including an entire site description.

urls.py

from django.conf.urls.defaults import *
from feeds import *

#Here you add a dictionary of feeds with a slug you want them to correspond to

site_feeds = {
        'blog':BlogFeed
}

urlpatterns = patterns('',
  #Lots of patterns omitted here
  (r'^feeds/(?P< url >.*)/$', 'django.contrib.syndication.views.feed',{'feed_dict':site_feeds}),
)

This tells Django that for every time it encounters a request beginning with feeds, it should take the remainder of the url as a slug and find the corresponding feed class in site_feeds. There is only one step left, making the templates. Don’t worry, this is the easiest part.

Every feed needs two templates, although you can reuse templates by specifying the title_template and description_template in your feed class. Otherwise, Django will look for templates that match your feed’s slug identifier in the templates/feeds directory, where templates is your base directory for templates. In this case it will be looking for blog_title.html and blog_description.html. Both templates get passed one variable: obj, which represents a single item in the feed. Both are ridculously simple:

blog_title.html

{{ obj.title }}

blog_description.html

{{ obj.body }}

They are really that simple. You can, of course, apply all your favorite Django template filters or add extra formatting if you wish. If you want to include any other information that you might pull via template tags, you can use those as well. For example if you wanted to also include a comment count your description template would look like this:

blog_description.html

{% load comments %}
{% get_comment_count for blog.entry obj.id as comment_count %}
{{ obj.body }}
{{ comment_count }} comment{{ comment_count|pluralize }} on this entry.

By default, Django will serve up your feed as RSS 2.0, however, you can also create Atom feeds just as easily. You can even serve up both types of feeds by subclassing your BlogFeed class like so:

feeds.py

from django.contrib.syndication.feeds import Feed
from blog.models import Entry
from django.utils.feedgenerator import Atom1Feed

#For brevity's sake, I'm omitting the BlogFeed I described above.

class AtomBlogFeed(BlogFeed):
    feed_type = Atom1Feed
    subtitle = BlogFeed.description

That’s all there is to it! Simply assign it a feed slug and either create new templates or specify in the AtomBlogFeed class to use the same templates as BlogFeed.

It is possible to completely customize your feeds, but that’s a little out of the scope of this post. This basic approach should work for the majority of cases, and if you need to do something more advanced with your feed, take a moment to browse through the official documentation as there are a wealth of options available to you.

This may initially look like a lot of work, but believe me this takes no time at all. This site generates feeds for every kind of content, including by tag, and tag per category, and I was able to write all of those feeds and have them being served up in about twenty minutes. For a simple example like I am showing here you can be up with feeds in less than ten!

Django makes feed generation quick and easy, and like most aspects of Django, is a joy to work with. Go ahead, take a moment and play with it. If you need an app to work with, you can either flesh out this example or you can go through the official tutorial. Afterwards, I’m pretty sure you’ll be hooked. ;-)

Relaunch

Posted on Thursday, July 26, 2007 @ 04:07 CDT by Daniel Andrlik

Well, it took a long time, but I finally finished!

Welcome to the new Ministry of Intrigue. This site is now powered by Django, the marvelous Python framework many of you have heard me rave about again and again. It’s been a great experience and I cannot believe how much I learned along the way. At some point, when I’m not quite so exhausted I would like to take a moment and point out all the excellent resources that made it possible to do this, because if you’re willing to learn, there is so much you can do with this. I’ve already got plans for future projects. :-)

In the meantime, I am still tinkering with this site. There were a few features that I just had to cut out of the launch because they were too time consuming, and I’m trying to rectify my multitude of design sins. My goal is to have this whole site validate as XHTML Strict, and for the most part it does. However, there are still quite a few old entries that need to be cleaned up individually.

Feel free to poke around and let me know what you think. I’m sure I’ll find lots of bugs over the next few weeks.

UPDATE: Whoops! I was trying to be clever and ended up accidentally wiping the homepage info for all the old comments. I’ll try to get some of it restored, but I honestly probably will only be able to get a minority of the urls back. If you notice an issue and really care about getting it restored, let me know. Only past comments are affected, future comments will have the homepage link generated correctly.

Into The Past »