我刚刚开始使用django并正在配置网址。我可以映射不同的网址,如/ posts,/ posts / create等。不知怎的,我无法配置根网址,我不知道我在做什么错。这是我的配置:
urlpatterns = [
# Examples:
url(r'',homeViews.posts),
# url(r'^blog/', include('blog.urls')),
url(r'^posts/',homeViews.posts),
url(r'^createPost/',homeViews.createPost),
url(r'^createUser/',userViews.createUser),
url(r'^post/(?P<title>[a-z,A-Z]+)/$',homeViews.post),
]`
干杯!
答案 0 :(得分:1)
这是一个例子,我的朋友。
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'home.views.home',name='index'),
url(r'^contactanos/$', 'home.views.contacto',name='contacto'),
url(r'^post/$', 'home.views.blog',name='blog')
]