【发布时间】:2020-05-11 21:51:24
【问题描述】:
您好,我正在开发一个 React Frontend - Django rest 框架,将 API 用作后端。当我加载模型时,它返回此错误 404。我不确定如何将 /models 包含在 urls.py 中,以便能够加载 .json 文件。我可以使用 Media_URL 或 static_URL 来提供 json 文件吗?
Page not found (404)
Request Method: GET
Request URL: http://localhost:8000/models/movies.json
Using the URLconf defined in movieproject.urls, Django tried these URL patterns, in this order:
^api/movies/$ [name='movies-list']
^api/movies\.(?P<format>[a-z0-9]+)/?$ [name='movies-list']
^api/movies/(?P<pk>[^/.]+)/$ [name='movies-detail']
^api/movies/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$ [name='movies-detail']
^$ [name='api-root']
^\.(?P<format>[a-z0-9]+)/?$ [name='api-root']
The current path, models/movies.json, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
【问题讨论】:
标签: django django-rest-framework