一、下载须知
详情请看:
http://my.oschina.net/repine/blog/311500
二、安装步骤
1)创建一个新项目
django-admin startproject project_web1
目录结构
2)修改配置文件settings.py
添加一个blog的应用(记住末尾加:逗号)
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
)
修改下时区和语言信息:
LANGUAGE_CODE = 'zh-cn'
TIME_ZONE = 'Asia/Shanghai'
3)修改配置文件urls.py
解释说明:blog/index 地址对应的是blog/views.py里面的index函数
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'project_web1.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^admin/', include(admin.site.urls)),
url(r'^blog/index', 'blog.views.index'),
)
4)创建应用blog
django-admin startapp blog
5)修改blog/views.py (添加index函数)
from django.http import HttpResponse
def index(req):
return HttpResponse('<h1>hello welcome to Django!</h1>')
5) python .\manage.py runserver
PS D:\_python\project_web1> python .\manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
September 08, 2014 - 17:37:35
Django version 1.7, using settings 'project_web1.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
三、测试步骤
访问地址:http://localhost:8000/blog/index/
四、关于我们
本文author:数据的开拓者成员之一 江中炼
QQ群:248087140
学习交友,共享交流