我只是想将视图映射到 中的路径urls.py
,但是当我尝试它时会引发此错误:
Registration didn't return an HttpResponse object
网址.py
urlpatterns = patterns('',
(r'^Register/$', Registration),
(r'^Newuser/$', ProcessRegistration),
)
视图.py
def Registration(request):
RegForm = RegistrationForm(request.POST or None)
if request.method == 'POST':
if RegForm.is_valid():
clearUserName = RegForm.cleaned_data['userNm']
clearPass = RegForm.cleaned_data['userPass']
RegForm.save()
try:
return HttpResponseRedirect('/Newuser/?userNm=' + clearUserName)
except:
raise ValidationError(('Invalid request'), code='300') ## [ TODO ]: add a custom error page here.
else:
RegForm = RegistrationForm()
return render(request, 'VA/reuse/register.html', {
'RegForm': RegForm
})
def ProcessRegistration(request):
clearUserName = request.GET.get('userNm')
return HttpResponse("Wee")
当我访问时/Register
,它会引发上述错误。
知道为什么它不起作用吗?它正在返回一个响应Wee