python前端Django指南之Hello worldl输出
生活随笔
收集整理的這篇文章主要介紹了
python前端Django指南之Hello worldl输出
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.創建Django項目
python manage.py startapp +項目名
ptyhon manage.py startapp index
2.添加setting,py屬性
部分代碼 增加 ‘index’
3.創建templates文件夾再創建和編輯index.html文件
index.html源代碼
<!doctype html> <html lang="en"> <head><meta charset="UTF-8"><meta name="viewport"content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Hello World</title> </head> <body> <h1>Hello World</h1> </body> </html>4.配置views.py
views.py源代碼
from django.shortcuts import render def index(request):words='World!'return render(request,'index.html',context={'words':words}) # Create your views here.5.配置urls.py
urls.py源代碼
from django.contrib import admin from django.urls import path from index.views import indexurlpatterns = [path('admin/', admin.site.urls),path('',index) ]啟動項目命令python manage.py runserver這個是重點在Terminal中運行
結果圖
鼠標點擊超鏈接即可
總結
以上是生活随笔為你收集整理的python前端Django指南之Hello worldl输出的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 判断浏览器版本语句大全
- 下一篇: 网易新闻 时事新闻抓取链接