Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #18234: Avoided exception on flatpage add

  • Loading branch information...
commit 75743c189d5138e47fd139b154c42e3bb67361c8 1 parent c2055ee
@kmtracey kmtracey authored
View
2  django/contrib/flatpages/forms.py
@@ -31,7 +31,7 @@ def clean(self):
if self.instance.pk:
same_url = same_url.exclude(pk=self.instance.pk)
- if same_url.filter(sites__in=sites).exists():
+ if sites and same_url.filter(sites__in=sites).exists():
for site in sites:
if same_url.filter(sites=site).exists():
raise forms.ValidationError(
View
13 django/contrib/flatpages/tests/forms.py
@@ -78,3 +78,16 @@ def test_flatpage_admin_form_edit(self):
updated = f.save()
self.assertEqual(updated.title, "A test page")
+
+ def test_flatpage_nosites(self):
+ data = dict(url='/myflatpage1/', **self.form_data)
+ data.update({'sites': ''})
+
+ f = FlatpageForm(data=data)
+
+ self.assertFalse(f.is_valid())
+
+ self.assertEqual(
+ f.errors,
+ {'sites': [u'This field is required.']})
+
Please sign in to comment.
Something went wrong with that request. Please try again.