Python django.views.generic.edit.ModelFormMixin() Examples
The following are 4
code examples of django.views.generic.edit.ModelFormMixin().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.views.generic.edit
, or try the search function
.
Example #1
Source File: test_detail.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_deferred_queryset_context_object_name(self): class FormContext(ModelFormMixin): request = RequestFactory().get('/') model = Author object = Author.objects.defer('name').get(pk=self.author1.pk) fields = ('name',) form_context_data = FormContext().get_context_data() self.assertEqual(form_context_data['object'], self.author1) self.assertEqual(form_context_data['author'], self.author1)
Example #2
Source File: test_edit.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_get_form_checks_for_object(self): mixin = ModelFormMixin() mixin.request = RequestFactory().get('/') self.assertEqual({'initial': {}, 'prefix': None}, mixin.get_form_kwargs())
Example #3
Source File: test_edit.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_create_view_without_explicit_fields(self): class MyCreateView(CreateView): model = Author message = ( "Using ModelFormMixin (base class of MyCreateView) without the " "'fields' attribute is prohibited." ) with self.assertRaisesMessage(ImproperlyConfigured, message): MyCreateView().get_form_class()
Example #4
Source File: views.py From mapstory with GNU General Public License v3.0 | 5 votes |
def form_valid(self, form): self.object = form.save(commit=False) self.object.author = self.request.user self.object.save() return super(ModelFormMixin, self).form_valid(form)