Posts tagged as:

django

Django CSRF Migration

June 2, 2010

Like many of you, I am migrating all my Django sites to Django 1.2.1. For sites that are currently in production, I am doing the slow migration route. Just trying to get the site up with 1.2 without using any of the new features yet.
One thing that I ran into is the new CSRF support. [...]

Read the full article →

My Accidental Connection with Senator Ted Kennedy

August 28, 2009

Being Chinese in Boston, I always hear positive stories about the late Senator Ted Kennedy helping immigrants. In addition, I agree with most of his political views, he seemed like a good Senator. After learning of his death, I felt we had lost a great man. I added one of his biographies to my Amazon [...]

Read the full article →

Django Production Error Handler

March 6, 2009

I am working on an application that, besides providing a dynamic website, also talks to an iPhone application. What happens when the iPhone, or a web visitor, triggered a bug in the application?
Django actually provide a nice mechanism to report error in its “batteries included” goodness. You can easily setup the Django environment so that [...]

Read the full article →

Serving favicon in an Django App using Apache

August 13, 2008

I got a free few minutes to work on my own site here. Since I migrated the site from all static pages to Django served, I still haven’t put back the favicon icon back onto the site. The sites runs under a virtual host in apache2 at WebFaction. This is what you need to put [...]

Read the full article →

Resetting Django Admin Password

August 7, 2008

This barely qualifies for a blog post, but what to do if you loaded, via django-admin.py loaddata
a full json file from someone during testing, and don’t have their user’s password?
Just run the django-admin.py shell, and by hand reset all the passwords:
from django.contrib.auth.models import User
for u in Users:
u.set_password(’secret’)
u.save()
That’s why you have to keep your shell login [...]

Read the full article →

J2EE to Django, slides for the Presentation at Cambridge Python Meetup

June 29, 2008

I gave a short presentation on Django to the Cambridge Python Users group earlier. Nate has a great writeup of the event and the other presentations that evening. I just want to share the slides here. The slides are just visual reminders and do not stand on their own. If you want more info free [...]

Read the full article →

Django Tip: No leading slash for upload_to for FileField and ImageField

May 9, 2008

This is a common mistake. When defining a FileField or an ImageField, you need to specify
where the files are stored. This is done by specifying a relative path in the upload_to
argument. Django will then store your files in a subdirectory as named, under the MEDIA_ROOT
directory. But, don’t put a leading slash in the relative path. [...]

Read the full article →

Django Tip: Outputting list of items separated by commas, but only if it has more than one item

April 24, 2008

How many times do you need to do this? You have a list of things to output. The list can be empty, has one element, or more. You want to separate each items with a separator for readability. What do you do?
1. The simple but not reader friendly way:
toppings = [ 'cheese','tomatos','pineapple' ]
or toppings = [...]

Read the full article →

gettext on Leopard for Django Internationalization

January 30, 2008

I started working on one of my internationalized applications on the new Mac. I realized I did not install “gettext”, which is required by the make-messages and compile-messages scripts. I want to avoid installing things into OS X if I can. Then I found the easy way out:
1. Install poedit for os x. I need [...]

Read the full article →

Django on Leopard

January 20, 2008

Part of the reason I was waiting to switch from using Windows XP (gasp) as my Django development platform to OS X is that it is actually easier to install the platform on XP. Windows does not come with any of the tools, so it was a matter of installing the version that I need. [...]

Read the full article →