First Two Django Screencasts

It's always been a goal of mine to post screencasts here on my blog, but for whatever reason I never ended up getting around to it. Today, that all changes as I have created two new screencasts. Of course, this space is already very well-covered by both Michael Trier and Brian Rosner, so hopefully this adds something new to the conversation.

Setting up a Django Development Environment

In this screencast I show how I typically set up my Django development environment. It goes through installing Django by checking out the latest development version and linking it to the correct places on your system. It also talks about how to install reusable applications. Finally, it covers how to update all of those projects and keep a toolbox of snippets for your personal use.

The simple pylink command that I use in the screencast is this:

#!/bin/bash
ln -s `pwd`/$1 `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`/$1

UPDATE: Joshua Uziel has sent me a much more robust version of this script, which handles the edge cases much better. I highly recommend using this version instead of my one-liner.

#!/bin/bash

SITE_PACKAGES="$HOME/prog/python/site-packages"

if [ ! $SITE_PACKAGES ]
then
    SITE_PACKAGES=`python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`
fi

BASE=`basename $1`
DIR=`dirname $1`

cd $DIR
ln -sfnv `pwd`/$BASE $SITE_PACKAGES/$BASE

UPDATE2: Zachary Voase has updated this new version, and it seems to be even more improved. I'm loving this! He has also written a "pyunlink" script, which can be found here.

Please let me know in the comments if you have any other tips and tricks for setting up a development environment for Django.

Using Django-Pagination

Django-pagination is an application that I wrote and released a while ago, which I use all the time, but that hasn't really seen much attention. In this screencast, I show how to take an existing project with too much data on one page, and use django-pagination to quickly and easily paginate the items on the page. There is a bit more documentation for the project that's available in the project directory if you do a subversion checkout, and docstrings throughout the source code, if you're interested in how it works.

Keep in Mind

These are my very first screencasts, ever. I'm not entirely sure what I'm doing yet, and the only way I can improve is by your feedback. If you have any advice and/or criticisms of these screencasts, please don't keep your mouth shut--speak up, and let me know in the comments. Hopefully someone finds these useful, and thanks for watching!

77 Comments So Far...

By Empty at 2:03 p.m. on July 13, 2008

Wow, excellent work! These are great. You have a real engaging and pleasant sounding vocal delivery. Keep them up.

 

By huxley at 2:42 p.m. on July 13, 2008

The pagination one was great, gonna go back and check out the first one just because the second one was so good.

 

By Eric Florenzano at 2:44 p.m. on July 13, 2008

Wow, thanks for the kind words Empty and huxley!

 

By huxley at 3:50 p.m. on July 14, 2008

You deserve the praise, those are darned fine screencasts.

BTW, for those who don't know, Empty is Michael Trier of "This Week in Django" podcast fame (and responsible for some great Django screencasts), so praise from him is a sure sign you're doing great stuff.

 

By Andreas at 2:52 p.m. on July 13, 2008

Awesome. Really great sound and overall quality as empty already stated.

 

By John M at 2:57 p.m. on July 13, 2008

Outstanding!!

This reminds me of how I used to setup my laptop to do Foxpro development (long before webcasts).

This gives me a great starting point, and confirms some of the ideas I've already implemented for django development.

Keep up the excellent work Eric!

John

 

By nuggien at 3:10 p.m. on July 13, 2008

Great work. I hope you add more screencasts on other django topics.

 

By Eric Florenzano at 3:15 p.m. on July 13, 2008

That's the plan :) Thanks!

 

By Julian at 3:34 p.m. on July 13, 2008

The second screencast is great! I'll try django-pagination tomorrow and I hope it is as easy as in your screencast.

Maybe this is the wrong place for asking this, but is it possible to change the URLs from /foo/?page=42 to /foo/page/42/?

 

By Eric Florenzano at 3:40 p.m. on July 13, 2008

Thanks! Right now it's not possible to change away from the GET parameters, but I'd love to support an arbitrary URL scheme. Please open a ticket and let's see if we can figure it out.

BTW, the ticket tracker is here: http://code.google.com/p/django-pagination/issues/list

 

By Chris Hasenpflug at 4:54 p.m. on July 13, 2008

Very nicely done, Eric. Looking forward to more in the future!

One question I do have is the use of your toolbox module and keeping it in sync with your production server. It seems you must replicate the toolbox module there as well? For this reason, I tend to put things like that in the actual project folder.

 

By Eric Florenzano at 6:25 p.m. on July 13, 2008

I actually have a private repository that I use to sync my toolbox. But really it works well both ways. I tend to keep it globally accessible because it forces me to abstract my patterns for reuse rather than do one-off fixes for each project.

 

By James Tauber at 10 p.m. on July 13, 2008

Anything in your toolbox we should include with Pinax?

 

By Eric Florenzano at 11:08 p.m. on July 13, 2008

Not really. Most of it is fairly specific to my projects. Otherwise, it's stuff from djangosnippets that we have replacements for or use already in Pinax.

 

By Onno at 5:06 p.m. on July 13, 2008

superb, show more

 

By kevin at 6:21 p.m. on July 13, 2008

eric, you did a great job. i know these things aren't easy and take a lot of time. you did great. keep up the excellent work!

 

By Tony at 1:17 a.m. on July 14, 2008

Eric,
That was a great screencast - clean, easy to hear, and it's certainly shown the django-pagination application in a very good light!

You're in my RSS feeds now and I'll be looking forward to the next one!

Cheers,
Tone

 

By Niklas at 2:12 a.m. on July 14, 2008

Very nicely done. You have an engaging and relaxing voice and your topic was well-defined. I thought it was professional indeed.

 

By Greig at 3:09 a.m. on July 14, 2008

The pagination screencast is excellent, good length and good pace. I'll be giving pagination a look today because you made it look so easy ! Keep up the great work.

 

By Beshr at 3:18 a.m. on July 14, 2008

Great Screencasts!
Keep up the good work :)

 

By Israel at 5:59 p.m. on July 14, 2008

I must add that the pagination screencast was timely as i was looking at doing exactly this.

thanks

P.S: any chance at requesting screenshots? i would like to see on on django-comments-utils

 

By Brian Rosner at 9:25 p.m. on July 14, 2008

It might be a good idea to check out http://stephendeken.net/wiki/software/keycastr/ to show what key strokes you take when it is a bit more implicit.

By the way excellent job!

 

By Eric Florenzano at 12:14 a.m. on July 16, 2008

Thanks, that's an awesome tip! I'll probably use it for the next one.

 

By Leandro at 10:25 p.m. on July 14, 2008

It's amazing, thx for all dude..

Very simple to use.. perfect .. just a number and vouala!

thx !

 

By Al at 1:16 a.m. on July 15, 2008

Eric,

You said at the end of the video that pagination isn't fetching everything as it's lazy-loading. If you're not fetching the entire list, are you querying a second time to get the total count of rows, so you know how many pages are required in the paging?

Al.

 

By Eric Florenzano at 12:12 a.m. on July 16, 2008

Yes, it's not just one round-trip to the database. Behind the scenes, it uses Django's "Paginator" object, so if you want to delve into the exact performance tradeoffs, check that out.

 

By David, biologeek at 9:18 a.m. on July 15, 2008

I second that your voice is really good. The problem with a toolbox is the portability of your apps because it depends on your environment, if you want to release an app with an XFNField, you need to remember to copy it before.

I didn't know the pylink script, thanks! I often use manage.py to add the cwd to sys.path, it works fine too, at least for tests.

A small tip for the first screencast, you can use "cd" and it will go to your home folder even if you do not mention the "~".

Keep up :)

 

By Eric Florenzano at 12:11 a.m. on July 16, 2008

Thanks for the compliment!

About the toolbox: You're absolutely right. Like anything else, it's definitely a tradeoff.

Also, it's good to know about plain "cd". I didn't know that was possible!

 

By Liam at 4:03 p.m. on July 15, 2008

Very handy. Great presentation.

 

By dude at 4:07 p.m. on July 15, 2008

Good one!

 

By Arthur at 9:37 a.m. on July 16, 2008

Great screencasts! Did you decide on what specific topic the next one is going to be?

 

By vds at 11:42 a.m. on July 16, 2008

Thanks for your work, I wonder why not use a zc.buildout to create a development environment?

 

By Recep KIRMIZI at 1:39 p.m. on July 17, 2008

That was so cool.
Now i have new vision about how to setup the development enviroment. Before this video i was always doing the svn up && sudo python setup.py install but that pylink stuff is really cool. Thx. so much. now i m a subcriber of you :)

 

By Recep KIRMIZI at 6:31 p.m. on July 17, 2008

and maybe for newbies at linux you can explain howto add the ~/bin directory to the users path. liike adding
the export PATH=$PATH:~/bin
row to the
~/.bashrc
file. thx. again. And on linux. it doesn't allow you to make a symlink to the python path. using the command with sudo works fine.

Thx. again
Regards...

 

By Eric Florenzano at 10:23 p.m. on July 17, 2008

Good point, I really forgot that ~/bin was nonstandard! I should have pointed that out :(

 

By nasim at 6:34 p.m. on July 17, 2008

Great screencast! Waiting for more!

Is it possible to make a podcast stream in iTunes?

 

By Eric Florenzano at 10:26 p.m. on July 17, 2008

Yep! The URLs to know are these:

iTunes: itpc://djangoscreencasts.blip.tv/rss/itunes/
RSS: http://djangoscreencasts.blip.tv/rss
Miro: http://subscribe.getmiro.com/?url1=http://djangoscreencasts.blip.tv/rss

 

By Ak at 8:14 p.m. on July 18, 2008

I am new to the Mac/Mac's terminal and was wondering how you got your pylink script to save in the GNU nano section then go back to the regular terminal?

 

By Gil at 11:04 a.m. on July 19, 2008

Awesome screencasts !

Another nice addon to your development environment would be using bash CDPATH.

Create a nice shortcut to each of your apps by:

# export CDPATH='~ericflo/development/pyhton'

 

By Trey Piepmeier at 8:59 p.m. on July 19, 2008

These are great. Any plans on making one for setting up a development environment?

 

By wesr at 9:55 a.m. on July 22, 2008

Great screencasts! They remind me a lot of railscasts, which is a good thing. I've subscribed to your podcast. Please keep them coming! They are a joy to watch.

 

By Oscar at 4:08 a.m. on July 30, 2008

Awesome!

 

By bjornkri at 9:25 a.m. on July 31, 2008

Very cool!

Just wondering: I noticed you put your templates and apps under the 'twitterclone' project. Is that how you normally do things? How do you decide when an app belongs within a project or in the development directory? Where do you place your projects? Within the development directory or separately?

Thanks, looking forward to seeing and hearing more :)
-Björn

 

By James Deane at 4:34 a.m. on Aug. 5, 2008

Just watched the first screencast and was by FAR the best Django screencast I've seen so far. Explained everything clearly, didn't move on or clear the screen too quickly.

As someone who's never programmed before and learning from the ground up this was an invaluable first step. Look forward to seeing more from you in the future :)

 

By kyle at 11:22 a.m. on March 11, 2009

I am so lost in how to upload everything in python from django - I have python 2.6 and also have downloaded the stable verison of django and untarred it - I just don't know how to import the django stuff... :P - can anyone help?

 

By kyle at 11:24 a.m. on March 11, 2009

I have a windows and basically the ^D doesn't work for me in python

 

By rootart at 5:48 a.m. on March 20, 2009

Cool. Thanks. I am new with django but this is realy good article.

 

By generic propecia 5mg at 9:16 p.m. on April 9, 2009

[... - Hi! cool info -wery insightful. [... -

 

By Bobo at 3:20 a.m. on April 27, 2009

Wow really nice, just the function I was looking for.

I took both screencasts and learned alot from both of them and now I've a nice pagnation :-)

 

By Bobo at 3:28 a.m. on April 27, 2009

One question though...

I'm from Denmark and we use three special characters:

Æ Ø Å

When I change the "Next" and "Previous" I get some kind of unicode error:

"Caught an exception while rendering: 'utf8' codec can't decode bytes in position 830-832: invalid data"

Do you know how I can render the pagination.html in correct unicode?

 

By acomplia fda review at 5:44 a.m. on April 29, 2009

Good disposition! Total to favorite

 

By wholesale jewelry at 3:21 a.m. on May 22, 2009

Great Screencasts,pls update ur site often,i like ur site very much.

 

By price levitra at 3:32 a.m. on May 24, 2009

creditable info. good dlog

 

By ben10 oyunları at 3:02 a.m. on May 25, 2009

Great screencasts! They remind me a lot of railscasts, which is a good thing. I've subscribed to your podcast. Please keep them coming! They are a joy to watch

 

By michael at 4:46 a.m. on June 4, 2009

Great Screencast. Great app and very easy to install. Works just great!

Thanks.

 

By jewelry at 3:02 a.m. on June 5, 2009

jewelry

 

By jewelry at 3:02 a.m. on June 5, 2009

jewelry

 

By davmp at 5:13 p.m. on June 7, 2009

I'm curious why you've created this special process to 'install' things and link the bin scripts when doing 'python setup.py develop' in the Django checkout directory handles it for you? (Well, if you don't have setuptools installed, 'develop' sub-command doesn't exist so you'd need to do 'python setup.py install'.)

 

By jimmy scotte at 1 p.m. on June 8, 2009

<a href=http://www.nikeshoeswholesale.com>We</a> <a href=http://www.handbagsreplica.org>are</a> <a href=http://www.mobilephones-cheap.com>glad</a> <a href=http://www.uggbootsaleon.com>to</a> <a href=http://www.wholesalenikeshoes.com>see</a> this. thanks.

 

By caltins yang at 1:01 p.m. on June 8, 2009

yes, we agree.

 

By amany kylar at 1:02 p.m. on June 8, 2009

Great Screencasts, thanks.
please update the site often,I like this site very much.

 

By cheap wow gold at 4:50 a.m. on June 13, 2009

Thx for sharing the exciting info with us

 

By injection molding at 1:13 a.m. on June 14, 2009

Thaks Jack, nice!

 

By jewelry at 4:25 a.m. on June 15, 2009

jewelry,jewelry wholesale

 

By geocoder at 10:41 a.m. on June 17, 2009

wonderful addition to Django. Just builds on the django DRY principle.

 

By casino online at 7:20 p.m. on June 22, 2009

nice observation

 

By merchant accounts at 8:01 p.m. on June 22, 2009

I'm curious why you've created this special process to 'install' things and link the bin scripts when doing 'python setup.py develop' in the Django checkout directory handles it for you? (

 

By lingerie at 8:08 p.m. on June 22, 2009

I use GMail because it's very convenient and I like searching but I'm constantly worried about my independance and liberty. What if they sell me out, or go under or get hacked and so on and so on

 

By jordan shoes at 2:28 a.m. on June 25, 2009

Thaks Jack, nice!

 

By jordan shoes at 2:29 a.m. on June 25, 2009

Great Screencasts, thanks.
please update the site often,I like this site very much.

 

By ugg boots at 2:29 a.m. on June 25, 2009

wonderful addition to Django. Just builds on the django DRY principle.

 

By nike shoes at 2:30 a.m. on June 25, 2009

creditable info. good dlog

 

By tiffany jewellery at 2:31 a.m. on June 25, 2009

Great Screencast. Great app and very easy to install. Works just great!

Thanks.

 

By sexy costumes at 10:01 a.m. on June 28, 2009

I think you will make these projects into a success also!

 

By sare at 1:37 a.m. on July 2, 2009

 

By Stop Dreaming Start Action at 6:55 a.m. on July 2, 2009

this is very interesting. thanks for that. we need more sites like this. i commend you on your great content and excellent topic choices. i'm spreading the good word about this site to all my friends. it's been enjoyable and educational.

 

By Rusli Zainal Sang Visioner at 6:56 a.m. on July 2, 2009

Thank you very much for the information I really appreciate it!! a found this nice site

 

Voice your opinion...