Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Moved ModelForm check work when instance is given #783

Closed
wants to merge 2 commits into from

2 participants

@vanschelven

No description provided.

@claudep
Collaborator

Mmmh... I think your PR was only containing the tests. Anyway, committed in cc53d9b. Many thanks for noticing this forgotten patch.

@claudep claudep closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/modeltests/model_forms/tests.py
View
16 tests/modeltests/model_forms/tests.py
@@ -133,6 +133,9 @@ class ShortCategory(forms.ModelForm):
slug = forms.CharField(max_length=5)
url = forms.CharField(max_length=3)
+ class Meta:
+ model = Category
+
class ImprovedArticleForm(forms.ModelForm):
class Meta:
model = ImprovedArticle
@@ -277,6 +280,19 @@ class BadForm(ArticleForm, BaseCategoryForm):
['headline', 'slug', 'pub_date', 'writer', 'article', 'categories', 'status']
)
+
+ def test_invalid_meta_model(self):
+ class InvalidModelForm(forms.ModelForm):
+ class Meta:
+ pass # no model.
+ # can't create new form
+ with self.assertRaises(ValueError):
+ f = InvalidModelForm()
+ # even if you provide a model instance
+ with self.assertRaises(ValueError):
+ f = InvalidModelForm(instance=Category)
+
+
def test_subcategory_form(self):
class SubCategoryForm(BaseCategoryForm):
""" Subclassing without specifying a Meta on the class will use
Something went wrong with that request. Please try again.