【发布时间】:2019-07-09 17:43:01
【问题描述】:
我正在尝试从https://django-rest-framework.org 做一个快速入门教程。
这是我的urls.py
from django.urls import path, include
from rest_framework import routers
from main.views import MovieViewSet, CommentViewSet
router = routers.DefaultRouter()
router.register(r'movies', MovieViewSet)
router.register(r'comments', CommentViewSet)
urlpatterns = [
path('', include(router.urls)),
]
当我转到http://127.0.0.1:8000/movies/ 时,我得到了
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/movies/
Using the URLconf defined in movie_api.urls, Django tried these URL patterns, in this order:
^$ [name='api-root']
^\.(?P<format>[a-z0-9]+)/?$ [name='api-root']
The current path, movies/, didn't match any of these.
视图集和序列化程序按照教程中的方式实现。
我是不是累了,什么都没看到?
【问题讨论】:
-
您的消息与您的 urls.py 不匹配。什么是根 urls 文件?
-
我相信这是根urls.py文件,在settings.py旁边
-
它只是与您从 404 获得的列出的 url 不匹配
-
不匹配的是什么?
标签: django django-rest-framework