當前位置: 首頁>>代碼示例>>Python>>正文


Python edit.FormMixin方法代碼示例

本文整理匯總了Python中django.views.generic.edit.FormMixin方法的典型用法代碼示例。如果您正苦於以下問題:Python edit.FormMixin方法的具體用法?Python edit.FormMixin怎麽用?Python edit.FormMixin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.views.generic.edit的用法示例。


在下文中一共展示了edit.FormMixin方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_get_prefix

# 需要導入模塊: from django.views.generic import edit [as 別名]
# 或者: from django.views.generic.edit import FormMixin [as 別名]
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')) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:19,代碼來源:test_edit.py

示例2: test_get_form

# 需要導入模塊: from django.views.generic import edit [as 別名]
# 或者: from django.views.generic.edit import FormMixin [as 別名]
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.'
        ) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:18,代碼來源:test_edit.py

示例3: test_initial_data

# 需要導入模塊: from django.views.generic import edit [as 別名]
# 或者: from django.views.generic.edit import FormMixin [as 別名]
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) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:8,代碼來源:test_edit.py

示例4: test_get_context_data

# 需要導入模塊: from django.views.generic import edit [as 別名]
# 或者: from django.views.generic.edit import FormMixin [as 別名]
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) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:8,代碼來源:test_edit.py


注:本文中的django.views.generic.edit.FormMixin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。