mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #22486 -- Restored the ability to reverse views created using functools.partial.
Regression in 8b93b31487.
Thanks rcoup for the report.
This commit is contained in:
committed by
Tim Graham
parent
c3152e5bcd
commit
3c06b2f2a3
@@ -2,7 +2,7 @@ import warnings
|
||||
|
||||
from django.conf.urls import patterns, url, include
|
||||
|
||||
from .views import empty_view, absolute_kwargs_view
|
||||
from .views import empty_view, empty_view_partial, empty_view_wrapped, absolute_kwargs_view
|
||||
|
||||
|
||||
other_patterns = [
|
||||
@@ -54,6 +54,10 @@ with warnings.catch_warnings(record=True):
|
||||
url(r'^outer-no-kwargs/([0-9]+)/', include('urlpatterns_reverse.included_no_kwargs_urls')),
|
||||
url('', include('urlpatterns_reverse.extra_urls')),
|
||||
|
||||
# Partials should be fine.
|
||||
url(r'^partial/', empty_view_partial, name="partial"),
|
||||
url(r'^partial_wrapped/', empty_view_wrapped, name="partial_wrapped"),
|
||||
|
||||
# This is non-reversible, but we shouldn't blow up when parsing it.
|
||||
url(r'^(?:foo|bar)(\w+)/$', empty_view, name="disjunction"),
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from functools import partial, update_wrapper
|
||||
|
||||
from django.http import HttpResponse
|
||||
from django.views.generic import RedirectView
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
@@ -55,3 +57,11 @@ def login_required_view(request):
|
||||
|
||||
def bad_view(request, *args, **kwargs):
|
||||
raise ValueError("I don't think I'm getting good value for this view")
|
||||
|
||||
|
||||
empty_view_partial = partial(empty_view, template_name="template.html")
|
||||
|
||||
|
||||
empty_view_wrapped = update_wrapper(
|
||||
partial(empty_view, template_name="template.html"), empty_view,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user