在视图中,我收到错误消息:invalid literal for int() with base 10
views.py
author_id = request.POST.get('id_author')
input_author= Engineer.objects.get(id=author_id)
答案 0 :(得分:2)
POST
字典中的项目默认为字符串。您必须使用int
方法将它们转换为整数:
author_id = int(request.POST.get('id_author'))
input_author = Engineer.objects.get(id=author_id)