标签:设置 运行 cut tar types python iter settings ssi
django-admin startproject douban
//创建project
cd douban
python manage.py startapp books
//创建app项目
在douban文件夹下
1.vim books/views.py
//写入页面程序
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def hello(request):
return HttpResponse("hello douban!!")
2.vim douban/urls.py
//修改路由
from django.conf.urls import url
from django.contrib import admin
from books import views
urlpatterns = [
url(r‘^admin/‘, admin.site.urls),
url(r‘^hello/douban/$‘,views.hello),
]
3.vim douban/settings.py
//修改基本设置
INSTALLED_APPS = [
‘django.contrib.admin‘,
‘django.contrib.auth‘,
‘django.contrib.contenttypes‘,
‘django.contrib.sessions‘,
‘django.contrib.messages‘,
‘django.contrib.staticfiles‘,
‘books‘//添加books项
]
4.运行python manage.py runserver
在浏览器访问http://127.0.0.1:8000/hello/douban/
返回hello douban!!!即可
标签:设置 运行 cut tar types python iter settings ssi
原文地址:https://www.cnblogs.com/zhuzq/p/9534746.html