Living on the Edge

This Week in Django 30 - 2008-07-20

Posted on July 21, 2008

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

This week we discuss the NewForms-Admin merge into Trunk, DjangoCon, a few source commits, some cool projects from the community, and the Tip of the Week.

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

Downloads

AAC Enhanced Podcast (41.8 MB, 49:31, AAC)

MP3 Edition (34.1 MB, 49:31, MP3)

OGG Edition (27.9 MB, 49:31, 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 (0:47)

Tracking Trunk (15:04)

Community Catchup (26:16)

  • Kevin Fricovsky – joins the This Week in Django team as Community Evangelist. Kevin will be working to produce the show, contacting guests, gathering news items, coming up with ideas. Kevin has been doing this work regularly anyway so it’s great of him to team up with us to help out the program:
  • PyOhio – Reminder that this free one day conference is in Columbus, OH on July 26, 2008.
  • Twitter Search – via Kevin Fricovsky using the new Twitter Search capability to track all tweets about django.

Tip of the Week (38:32)

This tip comes to us via Ben Jao Ming in his post Django auto-translation of field values.

If you need to translate content in a field then gettext is not going to help you out. Since you can create your own custom fields it’s easy to wrap a CharField with the translation behavior:


from django.db import models
from django.utils.translation import gettext_lazy as _

class AutoTranslateField(models.CharField):
    __metaclass__ = models.SubfieldBase
    def to_python(self, value):
        return str(_(value))

Just add whatever translations you know of to the locale file and run compilemessages.

Thank You! (42:45)

This Week in Django 29 - 2008-07-13

Posted on July 15, 2008

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

This week we have a special guest, Kevin Fricovsky, that joins us as we talk about DjangoCon, EuroPython, a few source commits, some cool projects from the community, and the Tip of the Week.

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

Downloads

AAC Enhanced Podcast (74.2 MB, 1:31:20, AAC)

MP3 Edition (62.8 MB, 1:31:20, MP3)

OGG Edition (51.5 MB, 1:31:20, 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 (3:38)

“DjangoCon 2008. Venue: Googleplex, San Francisco Bay Area. Dates: 6th and 7th Sept. Official post will be on djangoproject.com soon.”

Tracking Trunk (14:27)

Branching and Merging (34:18)

Community Catchup (47:27)

  • django-treemenus – Very cool application by Julien Phalip that makes it easy to add tree menus to your Django app and manage the structure dynamically from the customized admin interface. View the 0.4 release post for more information.
  • First Two Django Screencasts – Eric Florenzano never sleeps. His first foray into screencasts are quite impressive. He covers: 1. Setting up a Django Environment 2. Using Django-Pagination

Tip of the Week (1:10:41)

Mike Axiak offers the following tip for getting started with contributing to Django source code.

1. Find a closed ticket that interests you. 2. Take a look at a closed ticket, but not the patch. 3. Check out the revision prior to the one that closed the ticket. 4. Write a patch for Django with your own implementation. 5. Compare your patch with the committed patch and try to learn from the differences.

Once you’re comfortable do it for real.

Thank You! (1:23:24)

  • Kevin Fricovsky

No TWiD This Week

Posted on July 07, 2008

Apologies to all but there will be no This Week in Django podcast this week. Enjoy the week off and we look forward to seeing you all next week on TWiD Live.

This Week in Django 28 - 2008-06-30

Posted on July 01, 2008

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

This week we talk about quite a few source commits (kicking-ass), some cool projects from the community, the Tip of the Week, and a question from the IRC.

Let us know if downloads are better for those of you in Europe.

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

Downloads

AAC Enhanced Podcast (50.3 MB, 1:01:06, AAC)

MP3 Edition (42 MB, 1:01:06, MP3)

OGG Edition (32.9 MB, 1:01:06, 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

Malcolm Tredinnick is back!!!

Tracking Trunk (1:08)

Community Catchup (19:28)

  • Kss in DjangoKSS is a javascript framework that aims to allow Ajax development without javascript. It uses stylesheets with CSS-compliant syntax to setup behaviours in the client and a set of well-defined commands that are marshalled back from the server to manipulate the DOM.

Tip of the Week (43:49)

Ever need to reorder the fields on your Model Form?


class TranslationForm(BookForm):
    translator = forms.CharField(max_length=40)

    def __init__(self, *args, **kwargs):
        super(TranslationForm, self).__init__(*args, **kwargs)
        self.fields.keyOrder = ['title', 'author', 'translator', 'publisher', 'copyright']

IRC Ad Nauseam (47:10)

Django IRC FAQ

Backwards Incompatible Changes Information

Charlie O’Keefe say, “I’ve gotten into designing restful URL schemes, basically organizing a web app around resources. Learning Django I was frustrated to find that nothing seems to be done this way. Is there any tool that can help with that?”

Thank You! (50:58)

This Week in Django 27 - 2008-06-22

Posted on June 23, 2008

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

This week we talk about the Django Software Foundation, some source commits, some cool projects from the community, a Tip of the Week. and a couple IRC items. It’s a packed show.

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

Downloads

AAC Enhanced Podcast (55.8 MB, 1:08:08, AAC)

MP3 Edition (46.8 MB, 1:08:08, MP3)

OGG Edition (38.5 MB, 1:08:08, 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

SPONSOR: This Week in Django is brought you by Justin Lilly, who according to all historic accounts, once scissor kicked Angela Landsbury. Thank you Justin.

Big News (2:18)

New foundation for Django – Lawrence-Journal World announces new Django foundation and code commits change license ownership.

Tracking Trunk (5:02)

Branching and Merging (9:50)

Community Catchup (15:57)

  • DebugFooter Redux – Last week we talked about Andreas Marr very cool Django Snippet to add debug information into the footer of each webpage. This week he did it one better based on some suggestions from our program. Now that’s what I call Podcast Driven Development™.

Tip of the Week (43:22)

This tip comes from Alexander Solovyov in his blog post Render To Improved.

Sometimes you want to return a RequestContext from a view. One way to do that is to specify the response code using a decorator.


@render_to('mytemplate.html')
def myview(request):
  return ({'id': 1, 'name':'empty'})

# example with override
@render_to('mytemplate.html')
def myview(request):
  return ({'name':'empty'}, 'override.html')

# python 2.3 example with override
def myview(request):
  return ({'name':'empty'}, 'override.html')
myview = render_to(myview, 'mytemplate.html')

You can also return a tuple where the second item is a string that overrides the default template specified in render_to.

IRC Ad Nauseam (51:11)

Django IRC FAQ

Backwards Incompatible Changes Information

What’s the difference between Abstract Base Classes and Multi-Table Inheritance?

Abstract Base Classes are where you provide a base class, like Person, and then a derived class like Employee. Django will create a single database table for the Person model that contains the combined fields from both the base and derived classes.

Multi-Table Inheritance also has the base and derived class but at the database level you end up with two tables: one for the base class and one for the derived class, with a one-to-one field added in to connect the two.

Again, we highly recommend the excellent post by Kevin Fricovsky that we mentioned in Community Catchup. Plus, as always, the excellent Django documentation.

Is there a way to pass the filter arguments as string to the QuerySet?

QuerySet parameters are standard Python keyword arguments, and can use standard keyword argument expansion.


Post.objects.filter(datetime__year=2008)

Post.objects.filter(**{'datetime__year': 2008})

Thank You!

This Week in Django 26 - 2008-06-16

Posted on June 17, 2008

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

This week we talk about the Django 1.0 Roadmap, EuroPython Sprint, tons of source commits, great stuff happening in the NewForms-Admin branch, some cool projects from the community, and the Tip of the Week.

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

Downloads

AAC Enhanced Podcast (32.4 MB, 55:28, AAC)

MP3 Edition (38.1 MB, 55:28, MP3)

OGG Edition (30.8 MB, 55:28, 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:37)

EuroPython Django Sprint – We are holding an official Django sprint, July 10th until saturday July 12th, during the EuroPython conference. Join us in the push to 1.0.

Tracking Trunk (9:19)

  • Fixed serialization for multi-model inheritance (7600)
    • Serializers were including all superclass fields in their output. Now only local fields are included.
    • Implicit OneToOne? primary keys were not correctly added to the metamodel, so they were always marked to be serialized, even though they were primary
    • Model saving was too aggressive about creating new parent class instances during deserialization. Raw save on a model now skips saving of the parent class.

Branching and Merging (17:06)

Community Catchup (29:58)

  • Django Dash Results – Congratulations to all the participants. Check the results for information on all the winners.
    • 1st Place – Benjamin Pollack and Tyler Hicks-Wright – Their site was a code review site with Mercurial integration.
    • 2nd Place – Eric Florenzano and Tony HauberFeedalizer is a syndication feed aggregation based on popular feeds ranked by users.
    • 3rd Place – Justin Lilly and Jannis Leidel – A site connecting developers & translators with rankings for translators and groupings.
  • A Better Serialization Framework – A series of interesting posts by fiam on creating what he calls a better serialization framework.

Tip of the Week (41:59)

If you have a template tag that you want to automatically load into context for all of your templates, you can take the same approach Django does with the built-in template tags.

This must be done early on in the load process, so in your __init__.py for the app or project, just do:


from django.template import add_to_builtins
add_to_builtins('template_utils.templatetags.generic_content')

Thank You! (44:56)

  • Code Swarm – Python – amazing swarm representation of Python code commits over years of time. You have to see this!

This Week in Django 25 - 2008-06-08

Posted on June 09, 2008

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

This week we talk about a few source commits, a discussion about releases, Some cool projects from the community, and the Tip of the Week.

We liked this one so much we decided to record it twice!

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

Downloads

AAC Enhanced Podcast (42.9 MB, 52:57, AAC)

MP3 Edition (36.4 MB, 52:57, MP3)

OGG Edition (28.3 MB, 52:57, 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

Tracking Trunk (4:05)

Community Catchup (15:58)

  • Django India – Google Group discussion for Django developers in India.
  • django-arcade – a Django pluggable app that gets a constantly updating list of flash games and swf files every day that you can include with a template tag into any project you want.

Tip of the Week (44:00)

Onno Timmerman sends us this tip with doing Internationalization.

I needed to give someone a django.po file. Normaly a user wants to edit it with Microsoft Word, even when you ask not to they tend to do it! Poedit is a great program that makes it easy to edit these files.

Poedit

Thank You! (45:39)

Intermediate Models – Ticket 6095 – Worked on by Eric Florenzano

Brian Rosner

Junk in the Trunk by Campfire Dusty Rootin’ Tootin’ Sing-A-Longs & Campfire Ditties

This Week in Django 24 - 2008-06-01

Posted on June 02, 2008

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

This week Eric Florenzano fills in while Michael is out. We talk to James Tauber about who he is and what Pinax is. A few trunk changes and some community bits.

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

Downloads

AAC Enhanced Podcast (32.7 MB, 44:47, AAC)

MP3 Edition (41.7 MB, 44:47, MP3)

OGG Edition (53.7 MB, 44:47, Vorbis)

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

Quick note, Brian Rosner did the audio in Michael’s absence. Its not as good as what Michael produces, but he is getting better with it :)

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 (0:25)

We’re back! Apologizes for last week’s cancellation. Michael’s wife gave birth to their 2nd child, Lucas Matthew Trier. Welcome to the world, Lucas!

James Tauber Interview (1:12)

  • James is the CTO at US-based startup mValent.
    • Tell us a little about mValent? Is Django involved?
  • How did you come to find and use Django?

Tracking Trunk (31:51)

Community Catchup (35:09)

  • sleepy-django – Sleepy, allows you to create a static site by rendering Django templates to HTML.

Thank You! (39:08)

  • Special thanks to Brian Rosner for handling the show production this week. You did an awesome job man.

This Week in Django - Cancelled

Posted on May 26, 2008

Due to the Memorial Day Weekend and the lack of any pressing news, we’ve decided to cancel the show this week. Brian Rosner and I hope you all have an opportunity to spend time with family and friends. We’ll be doing the same.

This Week in Django 23 - 2008-05-18

Posted on May 20, 2008

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)

This Week in Django 22 - 2008-05-11

Posted on May 13, 2008

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

This week we have discussion about a XSS vulnerability, Some cool projects and blog 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 (24.3 MB, 40:00, AAC)

MP3 Edition (27.5 MB, 40:00, MP3)

OGG Edition (21.7 MB, 40:00, 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

Tracking Trunk (1:26)

Community Catchup (7:56)

Tip of the Week (28:15)

How can I break apart my models.py file into individual files?

IRC Ad Nauseam (32:23)

Django IRC FAQ

Backwards Incompatible Changes Information

My login form Isn’t working the first attempt I login at. The second attempt, it works though. How is this possible?

You probably neglected to send a test cookie on the first view of whatever page your login form is at.

Thank You! (37:34)

More information on Brian Rosner: http://oebfare.com/ and http://twitter.com/brosner/.

This Week in Django 21 - 2008-05-04

Posted on May 06, 2008

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

This week we have a couple of special guests. First, Eric Florenzano joins us for most of the show, and provides special insight into a few conversation items. Secondly we privileged to have Francis Cleary on the program to discuss a couple Tip of the Week items. We also cover all the regular stuff plus stream the program live on ustream.

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

Downloads

AAC Enhanced Podcast (33.2 MB, 1:01:14, AAC)

MP3 Edition (42.1 MB, 1:01:14, MP3)

OGG Edition (31.9 MB, 1:01:14, 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

Tracking Trunk (2:50)

Branching & Merging (8:53)

Community Catchup (19:38)

  • Django l10n – Marc Garcia, who was on last week’s show provides a followup post that does a great job of pulling together the information we discussed as well as stuff we did not get time to cover.

Tip of the Week (36:16)

Francis Cleary is on the show with us this week to present his tip that he entered in the Win Cool Stuff Contest and was our grand prize winner.

Multiple view prefixes

Rather then have complex and long urls like so


urlpatterns += patterns('',
   (r'^$', 'mySite.Project.views.mainpage' ),
   (r'^custom/view/$', 'mySite.Project.views.'view_function'),
   (r'^lookup/tag/(?P<tag>\w+)/$', 'mySite.Project.views.tag_list'),
   (r'^users/$' , 'django.views.generic.list_detail.object_list', user_dict),
   (r'^recent/$','django.views.generic.list_detail.object_list', all_dict),
   (r^text/$', 'django.views.generic.date_based.object_detail', object_dict),
)

Take advantage of the first argument to the patterns() function to specify a prefix to apply to each view function. just make sure you have the += not just =.


urlpatterns += patterns('mySite.Project.views',
   (r'^$', 'mainpage'),
   (r'^custom/view/$', 'view_function'),
   (r'^lookup/tag/(?P<tag>\w+)/$', 'tag_list'),
)

urlpatterns += patterns('django.views.generic',
   (r'^users/$' , 'list_detail.object_list', user_dict),
   (r'^recent/$', 'list_detail.object_list', all_dict),
   (r'^(?P<year>\d{4})/$', 'date_based.archive_year', object_dict),
)

Advanced Generic Views

If you don’t want your urls.py filling up with dictionary or would like to do more complicated filtering or extra work to a list. Define view functions that return your generic view and dictionary.

In this example from the Django Book. We will use a generic view to display an author but we want to update the last_accessed data.


urls.py

from mysite.books.views import author_detail

urlpatterns = patterns('',
   #...
   (r'^authors/(?P<author_id>d+)/$', author_detail),
)

views.py

import datetime
from mysite.books.models import Author
from django.views.generic import list_detail
from django.shortcuts import get_object_or_404

def author_detail(request, author_id):
   # Look up the Author (and raise a 404 if she's not found)
   author = get_object_or_404(Author, pk=author_id)

   # Record the last accessed date
   author.last_accessed = datetime.datetime.now()
   author.save()

   # Show the detail page
   return list_detail.object_detail(
       request,
       queryset = Author.objects.all(),
       object_id = author_id,
   )

Rather then calling the generic view from the urls.py you can once again see how uncoupled things are in django and just return the generic view from your own wrapped view.

  • Are you generic? – Great earlier post by Wilson Miner on using Generic Views for non-programmers.

IRC Ad Nauseam (45:33)

Django IRC FAQ

Backwards Incompatible Changes Information

  • We have discussed the changes to the Paginator that occured during the PyCon 2008 sprints, but we are still seeing people tripping up over it. Paginator originally worked only on QuerySets, but has now been abstracted out. Paginiator is now generalized enough to work on lists. This is the reason for QuerySetPaginator. It special cases certain things to prevent performing the wrong operation on the QuerySet.

>>> from cameras.models import CameraImage
>>> CameraImage.objects.all().count()
248788L
>>> from django.core.paginator import Paginator 
>>> paginator = Paginator( CameraImage.objects.all(), 48, True)
>>> import time;start=time.time(); page = paginator.page(50); print time.time()-start
17.4773068428

Some questions about general IRC

We get lots of questions about IRC in general, so maybe a few little tidbits here and there:

Why don’t you use manners? When I say Thank You, you don’t respond.

Okay here’s the deal, there’s no reason to increase the noise level on IRC. That means although we appreciate the thanks, often we will not acknowledge it. So don’t take it personally.

I asked a question and no one responded. Why is that?

People will answer if they know. You can re-ask but please wait a bit. Don’t use the #django-dev channel, that’s the wrong thing to do.

It might be good to think about how you can rephrase the question.

Use the Django-Users Mailing list. It’s another avenue available.

Can anyone help with a NewForms-Admin Question?

Don’t ask to ask. Just ask straight away. It depends often on the area of the question. So it’s best to just ask your question.

Will “blank” work?

Try it. Often the best thing to do is try it. That’s what anyone will end up doing.

Couple other tips, read the FAQ, Backwards Incompatible Changes, and the Freenode FAQ.

Thank You! (58:20)

This Week in Django 20 - 2008-04-27

Posted on April 28, 2008

This Week in Django is a weekly podcast about all things Django. This week’s show is a huge show with lots of great features.

This is the second part of a two part series on Internationalisation. This week we are privileged to talk to Marc Garcia, Django’s Catalan translator, among many other things. Marc discusses the localisation side of things, helping us understand what’s required to get your web site localised.

Additionally, we also talk about QuerySet Refactor branch having been merged to trunk.

Finally, we have a special full length song by Django’s own Adrian Holovaty. It’s amazingly beautiful, so I encourage you to stay tuned for it.

Note: We apologize for the occasional audio drops during the interview with Marc Garcia. That’s just how these things go when calling across the globe.

Also, We’ve modified the compression scheme a bit, so let us know if the sound is better or worse.

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

Downloads

AAC Enhanced Podcast (57.5 MB, 1:12:02, AAC)

MP3 Edition (49.5 MB, 1:12:02, MP3)

OGG Edition (38.5 MB, 1:12:02, 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 (0:55)

QuerySet-Refactor Branch Merged!

As Malcolm Tredinnick mentioned on last week’s show, the Queryset-Refactor branch has been merged into trunk. Changeset 7477 makes that happen.

Over the past several months we have giving you a lot of information on the changes that contained in the Queryset Refactor modifications. We plan to get into those things more in next weeks show.

Adrian Holovaty Special Song

At the end of the program we will be presenting a special song by Adrian Holovaty. So stay tuned for that.

Special Feature – Localisation (5:21)

This week we are honored to be able to speak with Marc Garcia. Marc is the founder and CTO of Accopensys, a software development solutions company. Marc also maintains a blog called the The Best of Marc Garcia.

Marc has also been heavily involved in doing:

  • many translations on Catalan and Spanish languages,
  • main development of Spanish localflavor,
  • development of Transdb (http://code.google.com/p/transdb/) that allows Django field translations on database, and
  • development of some small multilanguage web sites using Django

On last week’s program Malcolm Tredinnick gave us some great information on internationalisation. This week we are going to get into localisation, which as I understand it is the process of translating a product into different languages or adapting a language for a specific country or region.

Translating Django

  • Let us start off with looking at translating Django itself. What is the process involved for localising Django internals?
  • What specific language elements cause you problems? Malcolm had touched on difficulty with pluralisation. Would you comment on that and possibly other areas that present special challenges?
  • What sort of resources are available to translators?
  • In the area of translating Django, are there specific changes that you feel should be made in order to make the whole process better and easier for translators?
  • Last week we discussed some problems with Django documentation and slang that is used, etc… causing problems for getting things translated. What perspective do you have about this?

Translating Websites

  • There’s two template tags, trans and blocktrans for translating strings in the template. What is the difference between the two and how would you decide to use one or the other?
  • What about translating database content? How is that achieved?
  • I recently ran across the django-rosetta project on google code. It is a very impressive admin screen for doing translation. Have you used this project? Are there any similar types of tools to assist translators?
    • Poedit – a cross-platform gettext catalogs (.po files) editor.
    • Msgfmt – a Unix utility that creates message object files from portable object files.

Miscellaneous

  • Anything else that we didn’t cover that you would like to mention?

Community Catchup (48:49)

Thank You! (1:05:50)

Special Song by Adrian Holovaty

Radiohead is holding a “contest” called Radiohead Remix, in which they’re inviting fans to remix the song called “Nude” from their latest album. They’ve released the raw tracks and are encouraging people to remix the tracks to create something different.

So Adrian sat down and did his own jazzy acoustic mix, and we asked him if we could play it for the show. His remix is called “Nude (jazzy acoustic),” and if you like it, please vote for it.

More Information

Keep track of Brian Rosner at his website

This Week in Django 19 - 2008-04-20

Posted on April 21, 2008

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

SPECIAL FEATURE – Internationalisation

This is the first part of a two part series on Internationalisation. This week we are privileged to talk to Malcolm Tredinnick, Django core developer. Malcolm educates us on what internationalisation is all about, how it is implemented in Django, and some of the areas that can be improved in the future.

Additionally, we also discuss a lot of changesets in the Queryset Refactor Branch, and a couple of blog posts from the Django community.

It is our longest show yet, but definitely worth your attention. This is a must listen podcast.

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

Downloads

AAC Enhanced Podcast (79.3 MB, 1:41:32, AAC)

MP3 Edition (69.8 MB, 1:41:32, MP3)

OGG Edition (56.8 MB, 1:41:32, 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

Special Feature – Internationalization (1:39)

Malcolm Tredinnick, Django core developer, joins us to discuss internationalisation. Malcolm has often played the role of expert on internationalization / localization issues, speaks several languages, and works closely with the Django translators.

To learn more about Malcolm Tredinnick, be sure to add his blog, Defying Classification, to your RSS feeds and listen to our interview with Malcolm on This Week in Django 13

  • What is the difference between internationalisation and localisation?
  • Python 3.0 will feature full unicode support. What does that mean for Django? Will there be any benefits?
  • I attended a discussion by Tim Bray, who I suppose is a recognized internationalisation expert, and by the end of the discussion I felt like the idea of creating truly internationlised applications is somewhat hopeless. What are your thoughts about this?
  • How does translation support appear to the end-user in something like Django? (how they set which language to use, what Django does, etc).
  • Justin Lilly, a Django user and rabid fan of the show, wanted to ask, “I’m curious how many different ways there are to declare gettext-like things.. ugettext, gettext, (as a commonly used alias).. any more I don’t know?” So what about it? What’s the differences?
  • What is the difference between unicode and utf-8? Is there a difference?
  • What sort of things do developers need to watch out for when writing code for an international audience?
  • What can we do to improve the support in third-party applications for Internationalisation?
    • People learn differently so maybe we need to explore as many ways as possible to educate people. We can use things like tutorials or screencasts.
    • James Bennett’s apps are internationalised.
  • Goal is to get Django to pass the Turkey test yet, but it’s a goal.
  • How do you handle sorting in Django?

Tracking Trunk (59:37)

  • Updated Markdown Filter to Support v1.7 (7423) – From the mailing list, “Additionally, the encoding argument has been removed from both markdown and Markdown. Markdown expects unicode (or ascii) input and it is the users responsibility to ensure that’s what is provided. Therefore, all output is in unicode. Only markdownFromFile accepts an encoding.”

Branching & Merging (1:01:57)

Community Catchup (1:24:12)