在官网学习过程中,视图集和路由器部分按照教程写完代码action部分报错如下:
查看decorators.py里面并没有action函数,网上查到改成detail_route,改完后重启程序时报错:
Unhandled exception in thread started by <function wrapper at 0x000000000ED3C908> Traceback (most recent call last): File "D:\Python27\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "D:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run self.check(display_num_errors=True) File "D:\Python27\lib\site-packages\django\core\management\base.py", line 385, in check include_deployment_checks=include_deployment_checks, File "D:\Python27\lib\site-packages\django\core\management\base.py", line 372, in _run_checks return checks.run_checks(**kwargs) File "D:\Python27\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "D:\Python27\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config return check_resolver(resolver) File "D:\Python27\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "D:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python27\lib\site-packages\django\urls\resolvers.py", line 310, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "D:\Python27\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python27\lib\site-packages\django\urls\resolvers.py", line 303, in urlconf_module return import_module(self.urlconf_name) File "D:\Python27\lib\importlib\__init__.py", line 37, in import_module __import__(name) File "D:\Django-project\restframe\restframe\urls.py", line 69, in <module> url(r'^', include(router.urls)), File "D:\Python27\lib\site-packages\rest_framework\routers.py", line 91, in urls self._urls = self.get_urls() File "D:\Python27\lib\site-packages\rest_framework\routers.py", line 354, in get_urls urls = super(DefaultRouter, self).get_urls() File "D:\Python27\lib\site-packages\rest_framework\routers.py", line 281, in get_urls view = viewset.as_view(mapping, **route.initkwargs) File "D:\Python27\lib\site-packages\rest_framework\viewsets.py", line 67, in as_view cls.__name__, key)) TypeError: SnippetViewSet() received an invalid keyword 'detail'
请问是什么原因,如何解决,求大神支招,万分感谢~