1.安装
pip install django
2.创建项目
d:/www/django文件夹下右键->打开dos窗口 输入: python C:\ProgramData\Miniconda3\Scripts\django-admin.py startproject novelnet 回车 d:/www/django下创建一novelnet项目(文件夹)
3.创建模板文件夹
novelnet同级目录下创建manager文件夹,
创建manager/templates文件夹
4.settings.py中添加
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘manager‘ ]
5.创建路由
novelnet文件夹下创建views.py
from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return render(request,‘shouye.html‘);
6.配置路由,urls.py中
from django.conf.urls import url from django.contrib import admin from novelnet import views urlpatterns = [ url(r‘^$‘,views.index), url(r‘^admin/‘, admin.site.urls), ]
7.运行
python manage.py runserver 0.0.0.0:8000
8.访问
浏览器:http://localhost:8000/