summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-04-01 22:46:46 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-04-01 22:46:46 +0000
commit624caace17dbb9e22f5a4c6c08937d68cbdbb066 (patch)
tree26e7b428926be78cc16b10cb6e682f27ecdd5d99 /django
parentdc832d7753a0c65db5eca5ce0b2d046bd0d299e8 (diff)
Fixed #9005: don't wig out when reversing a URL if SETTINGS_MODULE isn't set. While I was there, I fixed #10599 by re-raising the original error message, which is almost always a better idea. Thanks, Eric
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10350 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/core/management/__init__.py2
-rw-r--r--django/template/defaulttags.py19
2 files changed, 14 insertions, 7 deletions
diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py
index 4b40009e76..151b94ec45 100644
--- a/django/core/management/__init__.py
+++ b/django/core/management/__init__.py
@@ -323,7 +323,7 @@ def setup_environ(settings_mod, original_settings_path=None):
else:
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.%s' % (project_name, settings_name)
- # Import the project module. We add the parent directory to PYTHONPATH to
+ # Import the project module. We add the parent directory to PYTHONPATH to
# avoid some of the path errors new users can have.
sys.path.append(os.path.join(project_directory, os.pardir))
project_module = import_module(project_name)
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index c08ecc435c..c375b5bb1e 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -370,14 +370,21 @@ class URLNode(Node):
url = ''
try:
url = reverse(self.view_name, args=args, kwargs=kwargs)
- except NoReverseMatch:
- project_name = settings.SETTINGS_MODULE.split('.')[0]
- try:
- url = reverse(project_name + '.' + self.view_name,
+ except NoReverseMatch, e:
+ if settings.SETTINGS_MODULE:
+ project_name = settings.SETTINGS_MODULE.split('.')[0]
+ try:
+ url = reverse(project_name + '.' + self.view_name,
args=args, kwargs=kwargs)
- except NoReverseMatch:
+ except NoReverseMatch:
+ if self.asvar is None:
+ # Re-raise the original exception, not the one with
+ # the path relative to the project. This makes a
+ # better error message.
+ raise e
+ else:
if self.asvar is None:
- raise
+ raise e
if self.asvar:
context[self.asvar] = url