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

时间:2021-09-07 18:14:37

I have just started with django now and was configuring urls. I am able to map different urls like /posts, /posts/create etc. Somehow I am not able to configure root url, I am not sure what wrong I am doing. Here is my configuration :

我刚刚开始使用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),
]`

Cheers!

干杯!

1 个解决方案

#1


1  

here is an example, my friend.

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

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')  
]

#1


1  

here is an example, my friend.

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

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')  
]