+ -
当前位置:首页 → 问答吧 → django 的urls.py 规则不能被匹配

django 的urls.py 规则不能被匹配

时间:2011-04-14

来源:互联网

urls.py  :

from django.conf.urls.defaults import *
from djg import hello,hello2,hello3,index

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^mydjango/', include('mydjango.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # (r'^admin/', include(admin.site.urls)),
        (r'^hello$', hello),
        (r'^hello2$', hello2),
        (r'^.*$', index),       
)


dig.py :

#!/usr/bin/env python
#coding=utf-8

from django.http import HttpResponse

def hello(request):
    return HttpResponse("Hello world")


def hello2(request):
    return HttpResponse("Hello world two")


def index(request):
    return HttpResponse("interface is normal")


http://ip:port/hello 或者http://ip:port/hello2 都是返回 :interface is normal 。
如果 去除index , 出现规则不能被匹配 ...

环境 : django 1.1.14  + nginx 0.8.50  + flup 1.0.2 ,pcre 6.6系统自带 (centos5.2)

作者: zhmysh   发布时间: 2011-04-14

在线等待,那位帮忙解答一下啊。。。

作者: zhmysh   发布时间: 2011-04-15