0
我的urls.py是找不到网页(404)错误在Django
from django.conf.urls import patterns,url
from rango import views
urlpatterns=patterns('',url(r'^$',views.index,name='index'))
urlpatterns=patterns('',url(r'^about/$',views.about,name='about'))
我views.py是
from django.shortcuts import render
from rango.models import Category
# Create your views here.
from django.http import HttpResponse
def index(request):
category_list = Category.objects.order_by('-likes')[:5]
context_dict={'categories':category_list}
return render(request, 'rango/index.html', context_dict)
def about(request):
return HttpResponse("go to index")
当我试图去我越来越页面地址http://127.0.0.1:8000/rango未找到。但我可以去地址http://127.0.0.1:8000/rango/about。
当我删除urls.py中的about url模式时,我能够转到地址http://127.0.0.1:8000/rango而不是http://127.0.0.1:8000/rango/about,因为about url模式不存在。
我无法同时访问这两个网址。
Thanks.The问题解决了 –