0
我很困惑。我會承認自己是一個新人,但這應該起作用。 請參閱下面的代碼。正如所寫的.save()行被註釋掉一樣。django保存數據庫的作品,但返回500錯誤?
當我運行這個,everythings工作正常,如預期的那樣,數據沒有保存,'g'被返回。
如果我取消了.save()行
的表項是保住了,但一個500錯誤是回報。
任何幫助非常感謝。
def register_new_poll(request):
new_poll_name = request.POST.get('n','d')
new_poll_password = request.POST.get('w','')
new_poll_port = request.POST.get('p','d')
new_poll_ip = request.POST.get('i','d')
new_poll_duration = request.POST.get('d','d')
if new_poll_name != 'd' and new_poll_port != 'd' and new_poll_ip != 'd' and new_poll_duration != 'd':
try:
poll.objects.get(name=new_poll_name)
return HttpResponse("Already In Database");
except poll.DoesNotExist:
new_poll = poll(name=new_poll_name,ip=new_poll_ip,port=new_poll_port,password=new_poll_password,duration=new_poll_duration,last_contact_time=datetime.now(),users_at_last_contact=0)
write_poll_list()
#new_poll.save()
return HttpResponse("g");
except:
return HttpResponse("b");
pass
else:
return HttpResponse("b");
**錯誤日誌錯誤日誌錯誤日誌** – 2011-05-04 23:09:20