我正在学习Python3。我在网络服务器上安装了python和django。 但是我对网址有疑问。
这就是我尝试过的:
expnk.ru HelloDjango (1) HelloDjango (2) setting.py .......... urls.py cat ... any apps
python3 manage.py startapp cat
接下来我将转到HelloDjango(2)文件和已编辑文件setting.py
,为INSTALLED_APPS
并添加了'cat'
然后我正在做HelloDjango (2) -> urls.py
。我在该文件中添加了以下字符串:
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^cat/', include('cat.urls')),
url(r'^admin/', admin.site.urls),
url(r'^blog/', include('blog.urls')),
url(r'^test/', include('test.urls')),
]
cat -> urls.py
并添加到该文件中:from django.conf.urls import url, include
from django.contrib import admin
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
views
,该文件中的代码如下:from django.shortcuts import render
from django.http import HttpResponse
def index(response):
return HttpResponse("Hello world!")
# Create your views here.
我创建了类似于博客应用程序的cat应用程序,结果是:博客正在运行,而cat不是。