/*************************************************************************************** django 初试* 说明:* 昨天打搭了dgango的服务器,今天学一下怎么来输出一个hello world出来。* * 2016-8-6 深圳 南山平山村 曾剑锋*************************************************************************************/一、创建blog应用:django-admin startapp blog二、目录结构:aplex@aplex:~/website/mysite$ lsblog manage.py mysiteaplex@aplex:~/website/mysite$ tree.├── blog│ ├── admin.py│ ├── admin.pyc│ ├── __init__.py│ ├── __init__.pyc│ ├── models.py│ ├── models.pyc│ ├── tests.py│ ├── views.py│ └── views.pyc├── manage.py└── mysite├── __init__.py├── __init__.pyc├── settings.py├── settings.pyc├── urls.py├── urls.pyc└── wsgi.py2 directories, 17 filesaplex@aplex:~/website/mysite$ 三、settings配置:aplex@aplex:~/website/mysite$ cat mysite/settings.py......INSTALLED_APPS = ('django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','blog',)......四、urls配置:aplex@aplex:~/website/mysite$ cat mysite/urls.pyfrom django.conf.urls import patterns, include, urlfrom django.contrib import adminadmin.autodiscover()urlpatterns = patterns('',# Examples:# url(r'^$', 'mysite.views.home', name='home'),# url(r'^blog/', include('blog.urls')),url(r'^admin/', include(admin.site.urls)),url(r'^blog/index/$', 'blog.views.index'),)五、view:aplex@aplex:~/website/mysite$ cat blog/views.pyfrom django.shortcuts import renderfrom django.http import HttpResponse# Create your views here.def index(req):return HttpResponse('<h1>hello world</h1>')aplex@aplex:~/website/mysite$ 六、效果: