当我点击http://127.0.0.1:8000/segment_address但我收到404错误时:
这是我的urls.py
from addFixAPI import views
router = routers.DefaultRouter()
router.register(r'segment_address', views.search_addresses,base_name='segment_address')
urlpatterns = patterns('',
url(r'^', include(router.urls)),
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^locality/', include('locality.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^django-rq/', include('django_rq.urls')),
)
答案 0 :(得分:1)
首先,您应该检查“app”是否在主“urls”项目中注册了“urls”。
很明显,但我没有看到你包含这行
from django.conf.urls import url, include
from rest_framework import routers
答案 1 :(得分:0)
以防万一有人觉得它有用:在路由器中注册时不要使用 .as_view() 。如果您使用 url() 方法注册,则只需要 .as_view()。