Python django.views.generic.edit.FormMixin() Examples
The following are 4
code examples of django.views.generic.edit.FormMixin().
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_edit.py From djongo with GNU Affero General Public License v3.0 | 6 votes |
def test_get_prefix(self): """ Test prefix can be set (see #18872) """ test_string = 'test' rf = RequestFactory() get_request = rf.get('/') class TestFormMixin(FormMixin): request = get_request default_kwargs = TestFormMixin().get_form_kwargs() self.assertIsNone(default_kwargs.get('prefix')) set_mixin = TestFormMixin() set_mixin.prefix = test_string set_kwargs = set_mixin.get_form_kwargs() self.assertEqual(test_string, set_kwargs.get('prefix'))
Example #2
Source File: test_edit.py From djongo with GNU Affero General Public License v3.0 | 6 votes |
def test_get_form(self): class TestFormMixin(FormMixin): request = RequestFactory().get('/') self.assertIsInstance( TestFormMixin().get_form(forms.Form), forms.Form, 'get_form() should use provided form class.' ) class FormClassTestFormMixin(TestFormMixin): form_class = forms.Form self.assertIsInstance( FormClassTestFormMixin().get_form(), forms.Form, 'get_form() should fallback to get_form_class() if none is provided.' )
Example #3
Source File: test_edit.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_initial_data(self): """ Test instance independence of initial data dict (see #16138) """ initial_1 = FormMixin().get_initial() initial_1['foo'] = 'bar' initial_2 = FormMixin().get_initial() self.assertNotEqual(initial_1, initial_2)
Example #4
Source File: test_edit.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_get_context_data(self): class FormContext(FormMixin): request = RequestFactory().get('/') form_class = forms.Form self.assertIsInstance(FormContext().get_context_data()['form'], forms.Form)