Ticket #14797: 14797.diff

File 14797.diff, 2.5 KB (added by Gabriel Grant, 14 years ago)
  • tests/regressiontests/generic_views/edit.py

     
    77from regressiontests.generic_views.models import Artist, Author
    88from regressiontests.generic_views import views
    99
     10class ModelFormMixinTests(TestCase):
     11    def test_get_form(self):
     12        form_class = views.AuthorGetQuerySetFormView().get_form_class()
     13        self.assertEqual(form_class.Meta.model, Author)
    1014
    1115class CreateViewTests(TestCase):
    1216    urls = 'regressiontests.generic_views.urls'
  • tests/regressiontests/generic_views/tests.py

     
    11from regressiontests.generic_views.base import ViewTest, TemplateViewTest, RedirectViewTest
    22from regressiontests.generic_views.dates import ArchiveIndexViewTests, YearArchiveViewTests, MonthArchiveViewTests, WeekArchiveViewTests, DayArchiveViewTests, DateDetailViewTests
    33from regressiontests.generic_views.detail import DetailViewTest
    4 from regressiontests.generic_views.edit import CreateViewTests, UpdateViewTests, DeleteViewTests
     4from regressiontests.generic_views.edit import ModelFormMixinTests, CreateViewTests, UpdateViewTests, DeleteViewTests
    55from regressiontests.generic_views.list import ListViewTests
  • tests/regressiontests/generic_views/views.py

     
    143143
    144144class BookDetail(BookConfig, generic.DateDetailView):
    145145    pass
     146
     147class AuthorGetQuerySetFormView(generic.edit.ModelFormMixin):
     148    def get_queryset(self):
     149        return Author.objects.all()
  • django/views/generic/edit.py

     
    7272        if self.form_class:
    7373            return self.form_class
    7474        else:
    75             if self.model is None:
    76                 model = self.queryset.model
    77             else:
    78                 model = self.model
     75            model = self.get_queryset().model
    7976            return model_forms.modelform_factory(model)
    8077
    8178    def get_form(self, form_class):
Back to Top