编写第一个响应
创建文件夹blog/view
- 并创建
__init__.py
文件和article.py
- 修改
article.py
文件:
from django.http import HttpResponse
from django.shortcuts import render
def index(request):
return HttpResponse('ok')
设置项目urls.py
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^blog/', include(arg='blog.url', namespace='blog'))
]
设置应用url.py
from django.conf.urls import url
from django.contrib import admin
from view import article
urlpatterns = [
url(regex=r'^article/index/$', view=article.index, name='article$index'),
]
查看结果,访问:http://localhost:8000/blog/article/index/