這裏不區分大小寫的結果是我的看法:Django的現場查找返回即使__exact
@csrf_exempt
def api(request):
if request.method=="POST" and 'cmd' in request.POST and request.POST['cmd'] == "post":
try:
usr = Usr.objects.get(secret__exact=request.POST['secret'])
# ....
response = 'ok'
except Exception as ex:
response = 'fail'
return HttpResponse(response)
的Django仍返回正確的對象,甚至有錯誤的祕密(例如,如果我通過更換一個「A」'一個祕密)。怎麼了?
你是說''response'是_always_'確定嗎? – karthikr
如果DB中的祕密是'A1b2C',即使發佈的祕密是'a1b2C',repsonse也可以。如果我發佈了'b1b2C' – user2302807