当前位置: 代码迷 >> python >> 如何在Django 1.8中将应用程序URL包含到项目URL中?
  详细解决方案

如何在Django 1.8中将应用程序URL包含到项目URL中?

热度:86   发布时间:2023-06-14 08:51:30.0

我现在刚开始使用django,并且正在配置url。 我能够映射不同的URL,如/ posts,/ posts / create等。以某种方式,我无法配置root url,我不确定自己在做什么错。 这是我的配置:

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),
]`

干杯!

这是一个例子,我的朋友。

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')  
]
  相关解决方案