我正在尝试运行长爪,但是当我python manage.py migrate
时出现错误。
$python manage.py makemigrations catalog home
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 361, in execute
self.check()
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/urls/resolvers.py", line 398, in check
for pattern in self.url_patterns:
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/urls/resolvers.py", line 579, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/django/urls/resolvers.py", line 572, in urlconf_module
return import_module(self.urlconf_name)
File "/home/x/Documents/Longclaw/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/x/Documents/bakery/bakery/urls.py", line 10, in <module>
from longclaw import urls as longclaw_urls
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/longclaw/urls.py", line 2, in <module>
from longclaw.basket import urls as basket_urls
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/longclaw/basket/urls.py", line 2, in <module>
from longclaw.basket import api
File "/home/x/Documents/Longclaw/lib/python3.7/site-packages/longclaw/basket/api.py", line 1, in <module>
from rest_framework.decorators import detail_route, list_route
ImportError: cannot import name 'detail_route' from 'rest_framework.decorators' (/home/x/Documents/Longclaw/lib/python3.7/site-packages/rest_framework/decorators.py)
使用Python 3.7.2
答案 0 :(得分:6)
这是因为detail_route
已从DRF 3.8中弃用。您也可以检查他们的change-log。另外,您可以使用actions
装饰器。例如:
from rest_framework.decorators import action
@action(detail=True, methods=['post'])
def set_password(self, request, pk=None):
....