1. Skip to navigation
  2. Skip to content

This Week in Django 23 - 2008-05-18

This Week in Django is a weekly podcast about all things Django.

This week we talk about PyOhio, a source commit, Some cool projects / posts from the community, the Tip of the Week, and a question from the IRC.

Please see the Show Notes below for all the pertinent information and links

Downloads

AAC Enhanced Podcast (21.3 MB, 35:18, AAC)

MP3 Edition (24.3 MB, 35:18, MP3)

OGG Edition (19.5 MB, 35:18, Vorbis)

The Enhanced Podcast version contains screenshots and easy access links to all of the items we discuss throughout the podcast.

Feeds Available

iTunes Feeds are available. By subscribing using the iTunes feeds the podcasts will automatically be downloaded for you when we release them.

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

This Week in Django – OGG 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__ thisweekindjango.com.

Show Notes

Big News (1:14)

  • PyOhio – Regional Python conference to be held in Columbus, Ohio on July 26, 2008. It is one full day of Python fun, and it is free!
  • EuroPython – Monday 7th July – Saturday 12th July at Vilnius, Lithuania.

Tracking Trunk (3:59)


{
'changeset': 17, 
'ticket_new': 45, 
'ticket_close': 14, 
'ticket_update': 62, 
'patch': 28, 
'wiki_edit': 29
}

Branching and Merging

  • Check out brosner’s GitHub branch nfa_docs for his work on the newforms-admin documentation.

Community Catchup (8:47)

  • django-databasetemplateloader – Cool project by Janis Leidel. It loads template data from your database. All templates are editable via the admin interface. Nice for django.contrib.flatpages templates or default error templates.
  • Pro Django – Another Django book set to be released this year. This one is by Marty Alchin and we expect it to be very good advanced book on Django.

Tip of the Week (23:01)

The URLconf in Django will short-circuit when it matches a pattern. This is good because it can allow one to override URLs and map them to their own views. This is the fundamental base of how one can create their own admin interfaces.


from django.conf.urls.defaults import *

urlpatterns = patterns('',
    (r'^admin/bookstore/report/$', 'bookstore.admin_views.report'),
    (r'^admin/', include('django.contrib.admin.urls')),
)

Your view might look like this:


from mysite.books.models import Book
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.contrib.admin.views.decorators import staff_member_required

def report(request):
    return render_to_response(
        "admin/books/report.html",
        {'book_list' : Book.objects.all()},
        RequestContext(request, {}),
    )
report = staff_member_required(report)

It is important to use the staff_member_required decorator to protect the view from unwanted eyes.

IRC Ad Nauseam (28:16)

Django IRC FAQ

Backwards Incompatible Changes Information

I want to be able to check if a template variable is empty, how can I do that?

We see lots of questions that relate in some form or another to being able to test for empty or None conditions within the templates. The documentation on the if tag is pretty clear, but just as a refresher here’s how it plays out:

It uses Python’s Truth Value Testing. a template variable that is:

  • None
  • False
  • zero of any numeric type, for example, 0, 0L, 0.0, 0j.
  • any empty sequence, for example, ’’, (), [].
  • any empty mapping, for example, {}.
  • instances of user-defined classes, if the class defines a __nonzero__() or __len__() method, when that method returns the integer zero or bool value False.3.1

Thank You! (33:28)


Discussion