任何人都可以通过urls.py确认如何使用DRF引发NotFound异常吗?
urlpatterns = [
url(r'^blog/$', views.page),
url(r'^$, <?????>),
]
由于
答案 0 :(得分:1)
你应该在视图中提升它
urls.py:
urlpatterns = [
url(r'^blog/$', views.page),
url(r'^$', views.not_found),
]
views.py:
from rest_framework.exceptions import NotFound
from rest_framework.decorators import api_view
@api_view()
def not_found(request):
raise NotFound('Not Found!')