Example #1
0
def new_list(request):
    form = ItemForm(data=request.POST)
    if form.is_valid():
        list_ = List.objects.create()
        form.save(for_list=list_)
        return redirect(list_)
    else:
        return render(request, 'home.html', {"form": form})
Example #2
0
 def test_form_validation_for_blank_items(self):
     form = ItemForm(data={'text': ''})
     self.assertFalse(form.is_valid())
     self.assertEqual(form.errors['text'], [EMPTY_ITEM_ERROR])