方式一:

[root@iZ28cumdzmgZ muahao01]# vim urls.py

from django.conf.urls import patterns, include, url

from django.contrib import admin
from blog.views import index
urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'muahao01.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^blog/index/$', index),

)


方式二:


from django.conf.urls import patterns, include, url
from django.contrib import admin
#from blog.views import index
urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'muahao01.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^blog/index/$', 'blog.views.index'),
)

  

方式三:


from django.conf.urls import patterns, include, url
from django.contrib import admin
#from blog.views import index
urlpatterns = patterns('blog.views',
    # Examples:
    # url(r'^$', 'muahao01.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^blog/index/$', 'index'),
)

                 



通过url进行参数的传递:

[root@iZ28cumdzmgZ muahao01]# vim urls.py

from django.conf.urls import patterns, include, url
from django.contrib import admin
#from blog.views import index
urlpatterns = patterns('blog.views',
    # Examples:
    # url(r'^$', 'muahao01.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^blog/index/(?P\d{2})/$', 'index'),
)