本文整理汇总了Python中django.forms.models.ModelFormMetaclass方法的典型用法代码示例。如果您正苦于以下问题:Python models.ModelFormMetaclass方法的具体用法?Python models.ModelFormMetaclass怎么用?Python models.ModelFormMetaclass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.forms.models
的用法示例。
在下文中一共展示了models.ModelFormMetaclass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_invalid_loading_order
# 需要导入模块: from django.forms import models [as 别名]
# 或者: from django.forms.models import ModelFormMetaclass [as 别名]
def test_invalid_loading_order(self):
"""
Test for issue 10405
"""
class A(models.Model):
ref = models.ForeignKey("B", models.CASCADE)
class Meta:
model = A
fields = '__all__'
msg = (
"Cannot create form field for 'ref' yet, because "
"its related model 'B' has not been loaded yet"
)
with self.assertRaisesMessage(ValueError, msg):
ModelFormMetaclass('Form', (ModelForm,), {'Meta': Meta})
class B(models.Model):
pass
示例2: test_valid_loading_order
# 需要导入模块: from django.forms import models [as 别名]
# 或者: from django.forms.models import ModelFormMetaclass [as 别名]
def test_valid_loading_order(self):
"""
Test for issue 10405
"""
class C(models.Model):
ref = models.ForeignKey("D", models.CASCADE)
class D(models.Model):
pass
class Meta:
model = C
fields = '__all__'
self.assertTrue(issubclass(ModelFormMetaclass('Form', (ModelForm,), {'Meta': Meta}), ModelForm))