django学习之一在浏览器上完美打印基础内容

 

django学习之一在浏览器上完美打印基础内容

 

1.创建一个工程项目:django-admin startproject project_name

2.为项目创建一个app:python manage.py startapp app_name 或 django-admin startapp app_name

3.创建或更改数据库表或字段:python manage.py makemigrations && python manage.py migrate

4.创建超级管理员:python manage.py createsuperuser

5.项目文件

 

5.编辑代码views.py

# -*- coding: utf-8 -*-
from django.http import HttpResponse

def index(request):
    return HttpResponse(u'<h1>欢迎来到陈建文的学习基地')

6.编辑代码urls.py

from django.conf.urls import url
from django.contrib import admin
from learn import views as learn_views

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^$',learn_views.index)
]

7.运行项目:python.exe .\manage.py runserver 0.0.0.0:8000

8.查看成果

===================大功告成===================

===================QQ1071179133===================

 

posted @ 2017-07-21 18:35  chenjianwen  阅读(907)  评论(0编辑  收藏  举报