包括Django REST Framework网址返回404

时间:2014-08-24 19:56:56

标签: django django-rest-framework

当我尝试浏览http://localhost:8000/api/v1/api-dev/时,我得到404显示以下网址格式:

^api/v1/ ^api-dev/ ^login/$ [name='login']
^api/v1/ ^api-dev/ ^logout/$ [name='logout']

什么是空白和^?

这是来自app.urls的相关代码:

from django.conf.urls import patterns, url, include
urlpatterns = patterns('',

    url(r'^api/v1/', include('api.urls')),

)

来自api.urls:

from django.conf.urls import patterns, url, include
from rest_framework import routers
from api.views import views


urlpatterns = patterns('',

    url(r'^api-dev/', include('rest_framework.urls', namespace='rest_framework')),

)

2 个答案:

答案 0 :(得分:1)

哦,答案就是我是个白痴......没有

http://localhost:8000/api/v1/api-dev/

http://localhost:8000/api/v1/api-dev/login

答案 1 :(得分:0)

尝试从以下两者中删除网址:

(r'^api/v1/', include('api.urls')),
(r'^api-dev/', include('rest_framework.urls', namespace='rest_framework')),