簡體   English   中英

django 保存數據庫工作,但返回 500 錯誤?

[英]django saving database works, but returns 500 error?

我很困惑。 我承認自己是新手,但這應該可行。 請參閱下面的代碼。 如所寫,.save() 行已被注釋掉。

當我運行它時,一切正常,如預期的那樣,未保存數據並返回“g”。

如果我取消注釋 the.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");

ippoll中的一個字段。 請參閱粘貼的第 12 行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM