This makes it possible to run django.setup() in management commands that don't need a settings module. In addition it simplifies error handling. Thanks Claude for the review.
* Removed trailing whitespace. * Added newline to EOF if missing. * Removed blank lines at EOF. * Removed some stray tabs.