This Week in Django is a weekly podcast about all things Django.
This week we have our special guest Matthew Wensing on the show to discuss his work with the Django GIS Branch (GeoDjango). We also cover EveryBlock, Some cool projects from the community, the Tip of the Week, and a couple of questions from the IRC.
Please see the Show Notes below for all the pertinent information and links
Downloads
AAC Enhanced Podcast (32.9 MB, 58:00, AAC)
MP3 Edition (39.9 MB, 58:00, MP3)
The Enhanced Podcast version contains screenshots and easy access links to all of the items I discuss throughout the podcast.
Feeds Available
iTunes Feeds are available, we have just failed to mention it. So please choose the iTunes feed if you want automatic downloads in iTunes. Please show us some iTunes love.
iTunes Feeds
This Week in Django – AAC Edition
This Week in Django – MP3 Edition
Regular RSS Feeds
This Week in Django – AAC Edition
This Week in Django – MP3 Edition
Give Us Feedback
Want to give us some feedback on the show? We’re always looking for ideas or suggestions that will help improve each episode. Please contact us at feedback _at_url_ thisweekindjango.com.
Show Notes
Big News (1:03)
- EveryBlock The brain child of Adrian Holovaty, EveryBlock is a website that filters an assortment of local news by location so you can keep track of what’s happening on your block, in your neighborhood and all over your city. The first release of EveryBlock contains information for Chicago, San Francisco, and New York. All written in Django.
Branching & Merging (4:10)
Matthew Wensing, co-founder of Stormpulse, joined us to talk about the GIS Branch, also known as GeoDjango.
Community Catchup (27:51)
- Django People – Very cool site using google mashups to allow the Django community to get connected.
- Per-Function Cache Decorator – Cool snippet that adds a decorator that caches the decorated function for the amount of time specified. Great for expensive operations.
Tip of the Week (43:40)
The templatetag {% block %} has a not so known variable {{ block.super }}. It is documented, but it seems to be over looked. What this allows you to do is get the rendered output of the parent block and display it as you like. Take the following use case:
In a base.html you have the following bit of code:
{% block title %}My Cool Website{% endblock %}
Then in a template that extends the base.html template you want to be able to display “My Cool Website” as apart of each page:
{% extends "base.html" %}
{% block title %}My Sweet Page | {{ block.super }}{% endblock %}
The will display “My Sweet Page | My Cool Website”.
IRC Ad Nauseam (46:53)
Django IRC FAQ
Backwards Incompatible Changes Information
I just upgraded to the latest version and now I’m experiencing Unicode problems:
- Read the Unicode Branch Checklist
- Change the
__str__ methods on your models to be __unicode__ methods.
- Change string literals to be unicode strings. For example:
def __str__(self):
return u'Category: %s' % (self.name,)
I keep getting this error “Reverse query name for field ’%s’ clashes with field ’%s.%s’. Add a related_name argument to the definition for ’%s’.” How do I correct it?
The error message is extremely helpful and tells you what you need to do. There are a lot of different ways this error will appear but usually the fix is the same. You need to specify a related_name argument when defining your field.
The problem often arises because you have two fields on a model that are a ForeignKey to the same table. For instance:
class Episode(models.Model):
pub_date = models.DateTimeField()
title = models.CharField(max_length=255)
slug = models.SlugField(prepopulate_from=("title",), unique=True)
categories = models.ManyToManyField(Category)
body = models.TextField(blank=True)
producer = models.ForeignKey(User, related_name='episode_producers')
host = models.ForeignKey(User, related_name='episode_hosts')
u = User.objects.get(pk=1)
u.episode_producers
u.episode_hosts
Thank You! (55:31)