Beispiel #1
0
 def test_invalid_form(self):
     w = Whatever.objects.create(title='Foo', body='')
     data = {
         'title': w.title,
         'body': w.body,
     }
     form = WhateverForm(data=data)
     self.assertFalse(form.is_valid())
def add(request):
	if request.POST:
		form = WhateverForm(request.POST, request.FILES)
		if form.is_valid():
			form.save()
			return HttpResponseRedirect('/')
	else:
		form = WhateverForm()

	args = {}
	args.update(csrf(request))
	args['form'] = form
	return render_to_response('add.html', args)
Beispiel #3
0
def add(request):
    if request.POST:
        form = WhateverForm(request.POST, request.FILES)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/')
    else:
        form = WhateverForm()

    args = {}
    args.update(csrf(request))
    args['form'] = form
    return render_to_response('add.html', args)
Beispiel #4
0
	def test_invalid_form(self):
		w = Whatever.objects.create(title='Foo', body='')
		data = {'title': w.title, 'body': w.body,}
		form = WhateverForm(data=data)
		self.assertFalse(form.is_valid())