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)
- Weekly Trunk stats by Rob Hudson – (Rob’s Cogitations)
{
'changeset': 17,
'ticket_new': 45,
'ticket_close': 14,
'ticket_update': 62,
'patch': 28,
'wiki_edit': 29
}
- New setting that helps testing under twill
(7537)– Adds aDEBUG_PROPAGATE_EXCEPTIONSsetting that can be used for testing situations
Branching and Merging
- Check out brosner’s GitHub branch nfa_docs for his work on the newforms-admin documentation.
Community Catchup (8:47)
- Pocket Django – Paul Bissex describes how he simply setup Django on a jailbroken iPhone using the Cydia package manager.
- 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.
- Exploring Mixins with Django Model Inheritance – Another great post by Eric Florenzano discussing how to use mixins with the model inheritance features in Django trunk.
- Peevalizer.com – Speaking of Eric Florenzano, he and Tony Hauber just released Peevalizer.com a new social networking site for people to list and discuss things that irritate them.
- Web frameworks: a free software oriented study – following on last weeks discussion of lines of code comparisons between Rails and Django, MiningLabs presents a comparison between Rails, Django, and Seam. There’s lots of pretty graphs.
- 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.
- Django Admin Omnigraffle Stencil – Wonderful stencil for OmniGraffle (mac os x), created by Alex Lee, containing all of the common UI elements seen in the Django admin interface, as a tool for wireframing. This link came to us through Simon Willison’s blog.
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)
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
