Python django.forms.models.BaseModelFormSet() Examples
The following are 6
code examples of django.forms.models.BaseModelFormSet().
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.forms.models
, or try the search function
.
Example #1
Source File: test_checks.py From djongo with GNU Affero General Public License v3.0 | 6 votes |
def test_invalid_type(self): class FakeFormSet: pass class ValidationTestInline(TabularInline): model = ValidationTestInlineModel formset = FakeFormSet class TestModelAdmin(ModelAdmin): inlines = [ValidationTestInline] self.assertIsInvalid( TestModelAdmin, ValidationTestModel, "The value of 'formset' must inherit from 'BaseModelFormSet'.", 'admin.E206', invalid_obj=ValidationTestInline )
Example #2
Source File: test_checks.py From djongo with GNU Affero General Public License v3.0 | 6 votes |
def test_invalid_type(self): class FakeFormSet: pass class ValidationTestInline(TabularInline): model = ValidationTestInlineModel formset = FakeFormSet class TestModelAdmin(ModelAdmin): inlines = [ValidationTestInline] self.assertIsInvalid( TestModelAdmin, ValidationTestModel, "The value of 'formset' must inherit from 'BaseModelFormSet'.", 'admin.E206', invalid_obj=ValidationTestInline )
Example #3
Source File: test_checks.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_valid_case(self): class RealModelFormSet(BaseModelFormSet): pass class ValidationTestInline(TabularInline): model = ValidationTestInlineModel formset = RealModelFormSet class TestModelAdmin(ModelAdmin): inlines = [ValidationTestInline] self.assertIsValid(TestModelAdmin, ValidationTestModel)
Example #4
Source File: test_checks.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_inline_without_formset_class(self): class ValidationTestInlineWithoutFormsetClass(TabularInline): model = ValidationTestInlineModel formset = 'Not a FormSet Class' class TestModelAdminWithoutFormsetClass(ModelAdmin): inlines = [ValidationTestInlineWithoutFormsetClass] self.assertIsInvalid( TestModelAdminWithoutFormsetClass, ValidationTestModel, "The value of 'formset' must inherit from 'BaseModelFormSet'.", 'admin.E206', invalid_obj=ValidationTestInlineWithoutFormsetClass )
Example #5
Source File: test_checks.py From djongo with GNU Affero General Public License v3.0 | 5 votes |
def test_valid_case(self): class RealModelFormSet(BaseModelFormSet): pass class ValidationTestInline(TabularInline): model = ValidationTestInlineModel formset = RealModelFormSet class TestModelAdmin(ModelAdmin): inlines = [ValidationTestInline] self.assertIsValid(TestModelAdmin, ValidationTestModel)
Example #6
Source File: models.py From django-is-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
def smartmodelformset_factory(model, request, form=ModelForm, formfield_callback=None, formset=BaseModelFormSet, extra=1, can_delete=False, can_order=False, min_num=None, max_num=None, fields=None, exclude=None, widgets=None, validate_min=False, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None, formreadonlyfield_callback=None, readonly_fields=None, readonly=False): meta = getattr(form, 'Meta', None) if meta is None: meta = type(str('Meta'), (object,), {}) if getattr(meta, 'fields', fields) is None and getattr(meta, 'exclude', exclude) is None: warnings.warn("Calling modelformset_factory without defining 'fields' or " "'exclude' explicitly is deprecated", PendingDeprecationWarning, stacklevel=2) form = smartmodelform_factory( model, request, form=form, fields=fields, exclude=exclude, formfield_callback=formfield_callback, widgets=widgets, localized_fields=localized_fields, labels=labels, help_texts=help_texts, error_messages=error_messages, formreadonlyfield_callback=formreadonlyfield_callback, readonly_fields=readonly_fields, readonly=readonly ) FormSet = smartformset_factory( form, formset, extra=extra, min_num=min_num, max_num=max_num, can_order=can_order, can_delete=can_delete, validate_min=validate_min, validate_max=validate_max ) FormSet.model = model return FormSet