'instancemethod' object has no attribute '__getitem__'

后端 未结 1 1261
说谎
说谎 2021-01-08 01:23

I keep getting this error:

TypeError: \'instancemethod\' object has no attribute \'__getitem__\'

With my particular view on a django site I

相关标签:
1条回答
  • 2021-01-08 02:10

    The problem is in this line tel = request.POST.get['tel_number']. If you are using .get you should pass the key as an argument:

    tel = request.POST.get('tel_number') # if key is not present by default it will return None
    

    Otherwise you can do this:

    tel = request.POST['tel_number'] # raise KeyError Exception if key is not present in dict
    
    0 讨论(0)
提交回复
热议问题