diff --git a/django/http/request.py b/django/http/request.py index 2c19e4ee8c4..ad18706e1e3 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -44,6 +44,7 @@ class HttpRequest(object): self.path = '' self.path_info = '' self.method = None + self.resolver_match = None self._post_parse_error = False def __repr__(self): diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py index f6da4b2692b..8dc21e4bc98 100644 --- a/tests/urlpatterns_reverse/tests.py +++ b/tests/urlpatterns_reverse/tests.py @@ -9,7 +9,7 @@ from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist from django.core.urlresolvers import (reverse, resolve, get_callable, get_resolver, NoReverseMatch, Resolver404, ResolverMatch, RegexURLResolver, RegexURLPattern) -from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect +from django.http import HttpRequest, HttpResponseRedirect, HttpResponsePermanentRedirect from django.shortcuts import redirect from django.test import TestCase from django.utils import unittest, six @@ -529,6 +529,10 @@ class ResolverMatchTests(TestCase): resolver_match = response.resolver_match self.assertEqual(resolver_match.url_name, 'test-resolver-match') + def test_resolver_match_on_request_before_resolution(self): + request = HttpRequest() + self.assertIsNone(request.resolver_match) + class ErroneousViewTests(TestCase): urls = 'urlpatterns_reverse.erroneous_urls'