python入门(一) django hello world demo

一、创建项目  

《python入门(一) django hello world demo》

二、项目结构

《python入门(一) django hello world demo》

 

三、hello.py

from django.shortcuts import render


def hello(request):
    context = {}
    context['hello'] = 'Hello World!'
    return render(request, 'hello.html', context)

四、urls.py

from django.conf.urls import url
from django.contrib import admin
from hello import hello

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^hello/', hello.hello),

]

五、hello.html

 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>hello</title>
</head>
<body>
<h1>{{ hello }}</h1></body>
</html>

六、启动

《python入门(一) django hello world demo》

七、访问

《python入门(一) django hello world demo》

 

 

 

    原文作者:python入门
    原文地址: https://my.oschina.net/fengshuzi/blog/754105
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞