diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
index 5f5f959..d0a073b 100644
a
|
b
|
class BaseDateListView(MultipleObjectMixin, DateMixin, View):
|
171 | 171 | def get(self, request, *args, **kwargs): |
172 | 172 | self.date_list, self.object_list, extra_context = self.get_dated_items() |
173 | 173 | context = self.get_context_data(object_list=self.object_list, |
174 | | date_list=self.date_list) |
| 174 | date_list=self.date_list, **kwargs) |
175 | 175 | context.update(extra_context) |
176 | 176 | return self.render_to_response(context) |
177 | 177 | |
diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py
index b9278bb..fe8460a 100644
a
|
b
|
class SingleObjectMixin(object):
|
96 | 96 | class BaseDetailView(SingleObjectMixin, View): |
97 | 97 | def get(self, request, *args, **kwargs): |
98 | 98 | self.object = self.get_object() |
99 | | context = self.get_context_data(object=self.object) |
| 99 | context = self.get_context_data(object=self.object, **kwargs) |
100 | 100 | return self.render_to_response(context) |
101 | 101 | |
102 | 102 | |
diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
index 3cade52..e46ff68 100644
a
|
b
|
class ProcessFormView(View):
|
129 | 129 | def get(self, request, *args, **kwargs): |
130 | 130 | form_class = self.get_form_class() |
131 | 131 | form = self.get_form(form_class) |
132 | | return self.render_to_response(self.get_context_data(form=form)) |
| 132 | return self.render_to_response( |
| 133 | self.get_context_data(form=form, **kwargs), |
| 134 | ) |
133 | 135 | |
134 | 136 | def post(self, request, *args, **kwargs): |
135 | 137 | form_class = self.get_form_class() |
diff --git a/django/views/generic/list.py b/django/views/generic/list.py
index 9797356..63f2808 100644
a
|
b
|
class BaseListView(MultipleObjectMixin, View):
|
116 | 116 | if not allow_empty and len(self.object_list) == 0: |
117 | 117 | raise Http404(_(u"Empty list and '%(class_name)s.allow_empty' is False.") |
118 | 118 | % {'class_name': self.__class__.__name__}) |
119 | | context = self.get_context_data(object_list=self.object_list) |
| 119 | context = self.get_context_data(object_list=self.object_list, **kwargs) |
120 | 120 | return self.render_to_response(context) |
121 | 121 | |
122 | 122 | |
diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py
index 652f66b..22f03bc 100644
a
|
b
|
from __future__ import absolute_import
|
3 | 3 | import datetime |
4 | 4 | |
5 | 5 | from django.core.exceptions import ImproperlyConfigured |
| 6 | from django.core.urlresolvers import reverse |
6 | 7 | from django.test import TestCase |
| 8 | from django.test.client import RequestFactory |
7 | 9 | |
| 10 | from . import views |
8 | 11 | from .models import Book |
9 | 12 | |
10 | 13 | |
… |
… |
class ArchiveIndexViewTests(TestCase):
|
21 | 24 | pubdate=base_date - datetime.timedelta(days=1)) |
22 | 25 | |
23 | 26 | def test_archive_view(self): |
24 | | res = self.client.get('/dates/books/') |
| 27 | res = self.client.get(reverse('books_archive')) |
25 | 28 | self.assertEqual(res.status_code, 200) |
26 | 29 | self.assertEqual(res.context['date_list'], Book.objects.dates('pubdate', 'year')[::-1]) |
27 | 30 | self.assertEqual(list(res.context['latest']), list(Book.objects.all())) |
… |
… |
class ArchiveIndexViewTests(TestCase):
|
37 | 40 | |
38 | 41 | def test_empty_archive_view(self): |
39 | 42 | Book.objects.all().delete() |
40 | | res = self.client.get('/dates/books/') |
| 43 | res = self.client.get(reverse('books_archive')) |
41 | 44 | self.assertEqual(res.status_code, 404) |
42 | 45 | |
43 | 46 | def test_allow_empty_archive_view(self): |
… |
… |
class ArchiveIndexViewTests(TestCase):
|
78 | 81 | self.assertEqual(res.context['page_obj'].number, 2) |
79 | 82 | self.assertEqual(list(res.context['latest']), list(Book.objects.all()[10:20])) |
80 | 83 | |
| 84 | def test_datebaselistview_regression_t17795(self): |
| 85 | factory = RequestFactory() |
| 86 | request = factory.get(reverse('books_archive')) |
| 87 | res = views.BookArchive.as_view()(request, foo='bar') |
| 88 | self.assertEqual(res.context_data.get('foo'), 'bar', |
| 89 | msg='context_data now contains the foo kwargs') |
| 90 | |
81 | 91 | |
82 | 92 | class YearArchiveViewTests(TestCase): |
83 | 93 | fixtures = ['generic-views-test-data.json'] |
… |
… |
class YearArchiveViewTests(TestCase):
|
132 | 142 | res = self.client.get('/dates/books/no_year/') |
133 | 143 | self.assertEqual(res.status_code, 404) |
134 | 144 | |
| 145 | |
135 | 146 | class MonthArchiveViewTests(TestCase): |
136 | 147 | fixtures = ['generic-views-test-data.json'] |
137 | 148 | urls = 'regressiontests.generic_views.urls' |
… |
… |
class WeekArchiveViewTests(TestCase):
|
291 | 302 | self.assertEqual(res.status_code, 200) |
292 | 303 | self.assertEqual(res.context['week'], datetime.date(2008, 9, 29)) |
293 | 304 | |
| 305 | |
294 | 306 | class DayArchiveViewTests(TestCase): |
295 | 307 | fixtures = ['generic-views-test-data.json'] |
296 | 308 | urls = 'regressiontests.generic_views.urls' |
… |
… |
class DayArchiveViewTests(TestCase):
|
373 | 385 | self.assertEqual(res.status_code, 404) |
374 | 386 | |
375 | 387 | def test_today_view(self): |
376 | | res = self.client.get('/dates/books/today/') |
| 388 | res = self.client.get(reverse('today_books')) |
377 | 389 | self.assertEqual(res.status_code, 404) |
378 | 390 | res = self.client.get('/dates/books/today/allow_empty/') |
379 | 391 | self.assertEqual(res.status_code, 200) |
380 | 392 | self.assertEqual(res.context['day'], datetime.date.today()) |
381 | 393 | |
| 394 | |
382 | 395 | class DateDetailViewTests(TestCase): |
383 | 396 | fixtures = ['generic-views-test-data.json'] |
384 | 397 | urls = 'regressiontests.generic_views.urls' |
diff --git a/tests/regressiontests/generic_views/detail.py b/tests/regressiontests/generic_views/detail.py
index 0b5d873..ecb4697 100644
a
|
b
|
|
1 | 1 | from __future__ import absolute_import |
2 | 2 | |
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
| 4 | from django.core.urlresolvers import reverse |
4 | 5 | from django.test import TestCase |
| 6 | from django.test.client import RequestFactory |
5 | 7 | |
| 8 | from . import views |
6 | 9 | from .models import Artist, Author, Page |
7 | 10 | |
8 | 11 | |
9 | | class DetailViewTest(TestCase): |
| 12 | class DetailViewTests(TestCase): |
10 | 13 | fixtures = ['generic-views-test-data.json'] |
11 | 14 | urls = 'regressiontests.generic_views.urls' |
12 | 15 | |
… |
… |
class DetailViewTest(TestCase):
|
92 | 95 | |
93 | 96 | def test_invalid_queryset(self): |
94 | 97 | self.assertRaises(ImproperlyConfigured, self.client.get, '/detail/author/invalid/qs/') |
| 98 | |
| 99 | def test_detailview_regression_t17795(self): |
| 100 | factory = RequestFactory() |
| 101 | request = factory.get(reverse('author_detail', kwargs={'pk': 1})) |
| 102 | res = views.AuthorDetail.as_view()(request, pk='1', foo='bar') |
| 103 | self.assertEqual(res.context_data.get('foo'), 'bar', |
| 104 | msg='context_data now contains the foo kwargs') |
diff --git a/tests/regressiontests/generic_views/edit.py b/tests/regressiontests/generic_views/edit.py
index 2bd982e..aef8ba8 100644
a
|
b
|
from django.core.exceptions import ImproperlyConfigured
|
4 | 4 | from django.core.urlresolvers import reverse |
5 | 5 | from django import forms |
6 | 6 | from django.test import TestCase |
| 7 | from django.test.client import RequestFactory |
7 | 8 | from django.utils.unittest import expectedFailure |
8 | 9 | |
9 | 10 | from . import views |
… |
… |
class ModelFormMixinTests(TestCase):
|
15 | 16 | form_class = views.AuthorGetQuerySetFormView().get_form_class() |
16 | 17 | self.assertEqual(form_class._meta.model, Author) |
17 | 18 | |
| 19 | |
18 | 20 | class CreateViewTests(TestCase): |
19 | 21 | urls = 'regressiontests.generic_views.urls' |
20 | 22 | |
… |
… |
class CreateViewTests(TestCase):
|
92 | 94 | self.assertEqual(res.status_code, 302) |
93 | 95 | self.assertRedirects(res, 'http://testserver/accounts/login/?next=/edit/authors/create/restricted/') |
94 | 96 | |
| 97 | def test_createview_regression_t17795(self): |
| 98 | factory = RequestFactory() |
| 99 | request = factory.get(reverse('author_create')) |
| 100 | res = views.AuthorCreate.as_view()(request, foo='bar') |
| 101 | self.assertEqual(res.context_data.get('foo'), 'bar', |
| 102 | msg='context_data now contains the foo kwargs') |
| 103 | |
| 104 | |
95 | 105 | class UpdateViewTests(TestCase): |
96 | 106 | urls = 'regressiontests.generic_views.urls' |
97 | 107 | |
… |
… |
class UpdateViewTests(TestCase):
|
228 | 238 | self.assertRedirects(res, 'http://testserver/list/authors/') |
229 | 239 | self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (xkcd)>']) |
230 | 240 | |
| 241 | |
231 | 242 | class DeleteViewTests(TestCase): |
232 | 243 | urls = 'regressiontests.generic_views.urls' |
233 | 244 | |
… |
… |
class DeleteViewTests(TestCase):
|
284 | 295 | self.fail('Should raise exception -- No redirect URL provided, and no get_absolute_url provided') |
285 | 296 | except ImproperlyConfigured: |
286 | 297 | pass |
287 | | |
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index 9ad00ed..536edaf 100644
a
|
b
|
|
1 | 1 | from __future__ import absolute_import |
2 | 2 | |
3 | 3 | from django.core.exceptions import ImproperlyConfigured |
| 4 | from django.core.urlresolvers import reverse |
4 | 5 | from django.test import TestCase |
| 6 | from django.test.client import RequestFactory |
5 | 7 | |
| 8 | from . import views |
6 | 9 | from .models import Author, Artist |
7 | 10 | |
8 | 11 | |
… |
… |
class ListViewTests(TestCase):
|
164 | 167 | for i in range(n): |
165 | 168 | Author.objects.create(name='Author %02i' % i, slug='a%s' % i) |
166 | 169 | |
| 170 | def test_listview_regression_t17795(self): |
| 171 | factory = RequestFactory() |
| 172 | request = factory.get(reverse('authors_list')) |
| 173 | res = views.AuthorList.as_view()(request, foo='bar') |
| 174 | self.assertEqual(res.context_data.get('foo'), 'bar', |
| 175 | msg='context_data now contains the foo kwargs') |
diff --git a/tests/regressiontests/generic_views/tests.py b/tests/regressiontests/generic_views/tests.py
index d387216..5693b06 100644
a
|
b
|
from .base import ViewTest, TemplateViewTest, RedirectViewTest
|
4 | 4 | from .dates import (ArchiveIndexViewTests, YearArchiveViewTests, |
5 | 5 | MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, |
6 | 6 | DateDetailViewTests) |
7 | | from .detail import DetailViewTest |
| 7 | from .detail import DetailViewTests |
8 | 8 | from .edit import (ModelFormMixinTests, CreateViewTests, UpdateViewTests, |
9 | 9 | DeleteViewTests) |
10 | 10 | from .list import ListViewTests |
diff --git a/tests/regressiontests/generic_views/urls.py b/tests/regressiontests/generic_views/urls.py
index 090ec73..787676a 100644
a
|
b
|
urlpatterns = patterns('',
|
28 | 28 | views.ObjectDetail.as_view()), |
29 | 29 | url(r'^detail/artist/(?P<pk>\d+)/$', |
30 | 30 | views.ArtistDetail.as_view(), |
31 | | name="artist_detail"), |
| 31 | name='artist_detail'), |
32 | 32 | url(r'^detail/author/(?P<pk>\d+)/$', |
33 | 33 | views.AuthorDetail.as_view(), |
34 | | name="author_detail"), |
| 34 | name='author_detail'), |
35 | 35 | (r'^detail/author/bycustompk/(?P<foo>\d+)/$', |
36 | 36 | views.AuthorDetail.as_view(pk_url_kwarg='foo')), |
37 | 37 | (r'^detail/author/byslug/(?P<slug>[\w-]+)/$', |
… |
… |
urlpatterns = patterns('',
|
54 | 54 | views.AuthorDetail.as_view(queryset=None)), |
55 | 55 | |
56 | 56 | # Create/UpdateView |
57 | | (r'^edit/artists/create/$', |
58 | | views.ArtistCreate.as_view()), |
| 57 | url(r'^edit/artists/create/$', |
| 58 | views.ArtistCreate.as_view(), |
| 59 | name='author_create'), |
59 | 60 | (r'^edit/artists/(?P<pk>\d+)/update/$', |
60 | 61 | views.ArtistUpdate.as_view()), |
61 | 62 | |
… |
… |
urlpatterns = patterns('',
|
94 | 95 | views.SpecializedAuthorDelete.as_view()), |
95 | 96 | |
96 | 97 | # ArchiveIndexView |
97 | | (r'^dates/books/$', |
98 | | views.BookArchive.as_view()), |
| 98 | url(r'^dates/books/$', |
| 99 | views.BookArchive.as_view(), |
| 100 | name='books_archive'), |
99 | 101 | (r'^dates/books/context_object_name/$', |
100 | 102 | views.BookArchive.as_view(context_object_name='thingies')), |
101 | 103 | (r'^dates/books/allow_empty/$', |
… |
… |
urlpatterns = patterns('',
|
116 | 118 | views.DictList.as_view(paginate_by=1)), |
117 | 119 | url(r'^list/artists/$', |
118 | 120 | views.ArtistList.as_view(), |
119 | | name="artists_list"), |
| 121 | name='artists_list'), |
120 | 122 | url(r'^list/authors/$', |
121 | 123 | views.AuthorList.as_view(), |
122 | | name="authors_list"), |
| 124 | name='authors_list'), |
123 | 125 | (r'^list/authors/paginated/$', |
124 | 126 | views.AuthorList.as_view(paginate_by=30)), |
125 | 127 | (r'^list/authors/paginated/(?P<page>\d+)/$', |
… |
… |
urlpatterns = patterns('',
|
200 | 202 | views.BookDayArchive.as_view()), |
201 | 203 | |
202 | 204 | # TodayArchiveView |
203 | | (r'dates/books/today/$', |
204 | | views.BookTodayArchive.as_view()), |
| 205 | url(r'dates/books/today/$', |
| 206 | views.BookTodayArchive.as_view(), |
| 207 | name='today_books'), |
205 | 208 | (r'dates/books/today/allow_empty/$', |
206 | 209 | views.BookTodayArchive.as_view(allow_empty=True)), |
207 | 210 | |