Ticket #15125: introspec_meta.2.diff
File introspec_meta.2.diff, 2.8 KB (added by , 14 years ago) |
---|
-
django/views/generic/edit.py
86 86 kwargs.update({'instance': self.object}) 87 87 return kwargs 88 88 89 def get_queryset(self): 90 """ 91 Get the queryset to look an object up against. May not be called if 92 `get_object` is overridden. 93 """ 94 if self.queryset is None: 95 if self.form_class: 96 return self.form_class._meta.model._default_manager.all() 97 else: 98 return super(ModelFormMixin, self).get_queryset() 99 89 100 def get_success_url(self): 90 101 if self.success_url: 91 102 url = self.success_url % self.object.__dict__ -
tests/regressiontests/generic_views/edit.py
201 201 except ImproperlyConfigured: 202 202 pass 203 203 204 def test_update_with_form_class(self): 205 a = Author.objects.create( 206 name='Randall Munroe', 207 slug='randall-munroe', 208 ) 209 res = self.client.post('/edit/author/%d/update/formclass/' % a.pk, 210 {'name': 'Randall Munroe (author of xkcd)', 'slug': 'randall-munroe'}) 211 self.assertEqual(res.status_code, 302) 212 self.assertRedirects(res, 'http://testserver/edit/authors/create/') 213 self.assertQuerysetEqual(Author.objects.all(), ['<Author: Randall Munroe (author of xkcd)>']) 214 204 215 class DeleteViewTests(TestCase): 205 216 urls = 'regressiontests.generic_views.urls' 206 217 -
tests/regressiontests/generic_views/urls.py
1 1 from django.conf.urls.defaults import * 2 from django.views.generic import TemplateView 2 from django.views.generic import TemplateView, UpdateView 3 from regressiontests.generic_views.forms import AuthorForm 3 4 4 5 import views 5 6 … … 64 65 views.NaiveAuthorUpdate.as_view()), 65 66 (r'^edit/author/(?P<pk>\d+)/update/redirect/$', 66 67 views.NaiveAuthorUpdate.as_view(success_url='/edit/authors/create/')), 68 (r'^edit/author/(?P<pk>\d+)/update/formclass/$', 69 UpdateView.as_view(form_class=AuthorForm, 70 success_url='/edit/authors/create/')), 67 71 (r'^edit/author/(?P<pk>\d+)/update/interpolate_redirect/$', 68 72 views.NaiveAuthorUpdate.as_view(success_url='/edit/author/%(id)d/update/')), 69 73 (r'^edit/author/(?P<pk>\d+)/update/$',