Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/musics/views.py中的detail函数 #3

Open
CrisJk opened this issue May 9, 2018 · 6 comments
Open

/musics/views.py中的detail函数 #3

CrisJk opened this issue May 9, 2018 · 6 comments

Comments

@CrisJk
Copy link

CrisJk commented May 9, 2018

新的框架中取消了from rest_framework.decorators import detail_route, list_route ,改成了from rest_framework.decorators import action .

@detail_route(methods=['get'])
def detail(self, request, pk=None):

这句会报TypeError, bool object is not callable错误

解决办法是更改函数名detail

我在运行这个tutorial的时候花了近30分钟的时间才找到这个错误,希望后面学习的人可以避免这个问题

@twtrubiks
Copy link
Owner

@CrisJk requirements.txt 中有指定 django<2.0, 如果你是安裝 django 2.0 ,的確會遇到類似的問題,
但還是謝謝提醒。(本教學是依照 django<2.0 所寫的,有機會我再來寫 django 2.0 的教學 )

@CrisJk
Copy link
Author

CrisJk commented May 10, 2018

@twtrubiks 确实是我没有仔细看requirements.txt,谢谢你的辛苦创作

@hjf-codecrazy
Copy link

新的框架中取消了from rest_framework.decorators import detail_route, list_route ,改成了from rest_framework.decorators import action .

@detail_route(methods=['get'])
def detail(self, request, pk=None):

这句会报TypeError, bool object is not callable错误

解决办法是更改函数名detail

我在运行这个tutorial的时候花了近30分钟的时间才找到这个错误,希望后面学习的人可以避免这个问题

谢谢分享

@chien0515
Copy link

碰到一模一樣的問題,還好有找到這裡,感謝分享

@BigYoungs
Copy link

新的框架中取消了from rest_framework.decorators import detail_route, list_route ,改成了from rest_framework.decorators import action .

@detail_route(methods=['get'])
def detail(self, request, pk=None):

这句会报TypeError, bool object is not callable错误

解决办法是更改函数名detail

我在运行这个tutorial的时候花了近30分钟的时间才找到这个错误,希望后面学习的人可以避免这个问题

我也遇到这个问题了,困扰了一天,解决办法确实是改个名字,头大~~~

@twtrubiks
Copy link
Owner

可以參考 branch , 我之後有補充上去了
https://github.com/twtrubiks/django-rest-framework-tutorial/tree/django2#extra-actions-for-routing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants