use proper db exception for django 1.3-1.5
fix sqlite regression