django TypeError: 'module' object is not callable
原因:导入模块时直接把模块当函数使用
1 from rest_framework import reverse #import reverse module 2 3 4 5 @api_view(("GET",)) 6 def api_root(request, format=None): 7 return Response({ 8 "user": reverse("user-list", request=request, fromat=format), 9 "snippet": reverse("snippet-list", request=request, format=format) 10 })
导致结果:
解决方法:引入正确的函数而不是模型
from rest_framework.reverse import reverse