沒有年鹷限制的程式語言學習



 2017 年的蘋果開發者大會,有兩位特別的App開發者,
一位是年僅十歲,來自澳洲的亞裔小男孩Yuma,六歲開始學習架設網站,2016年開始鑽研App軟體開發,十歲的Yuma在App Store上,已經有五款App。

另一位則是高齡82歲,來自日本的若宮正子。
若宮正子之前在銀行工作了43年,退休後在家中照顧年邁的母親,發現自己因此減少許多跟朋友社交的機會,所以在60歲時才開始學習如何使用電腦。
數位時仢-60歲才接觸電腦、日本81歲奶奶開發出iPhone遊戲App
天下雜誌-82歲登蘋果大會!高中學歷、若宮正子為大家帶來勇氣

mezzanine



前置動作:
1. install Git
https://git-scm.com/
2. install Heroku Cli
https://devcenter.heroku.com/categories/command-line
3. 申請 Heroku 帳號
Heroku | 搭配 Git 在 Heroku 上部署網站的手把手教學
5.準備好上傳網頁
5.1下載免費主題
https://github.com/thecodinghouse/mezzanine-themes
5.2下載並解壓縮,


1. 安裝虛擬工作環境
mkvirtualenv your-project-name

2. 安裝 Mezzanine
pip install mezzanine

3. 安裝購物車套件(選配, 有需要者裝)
pip install –U cartridge


4. 建立 Mezzanine 專案
mezzanine-project your-project-name

5. 切換至內容網站的工作目錄 , 並新增檔案 Procfile
5.1  cd your-project-name
5.2 建立新檔案 Procfile
內容如下(注意 your-project-name 是替換成自己的專案名稱。)
web: gunicorn --pythonpath your-project-name your-project-name.wsgi

完成時存檔時, 請注意
Procfile - Procfile - P要大寫,
                不要有副檔名

6. 編輯 wsgi.py
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
"""
WSGI config for mymezzanine project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name
from dj_static import Cling

os.environ.setdefault("DJANGO_SETTINGS_MODULE",
                      "%s.settings" % real_project_name("mymezzanine"))

application = Cling(get_wsgi_application())



7. 修訂 settings.py,
7.1 時區 TIME_ZONE = 'Asia/Taipei'
7.2 LANGUAGE_CODE = "zh-tw
7.3多語言 LANGUAGES = (     ('en', _('English')),     ('zh-tw', _('繁體中文')), )
7.4 USE_I18N = True
7.5 最下方加入三行
SECRET_KEY = "由 local_settings.py 複製而來"
ALLOWED_HOSTS = ["*"]
STATIC_ROOT = 'static'



# system time zone.
TIME_ZONE = 'Asia/Taipei' (約104列)

# If you set this to True, Django will use timezone-aware datetimes.
USE_TZ = True

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = "zh-tw"   (約111列)

# Supported languages
LANGUAGES = (
    ('en', _('English')),
    ('zh-tw', _('繁體中文')), (約116列)
)

# A boolean that turns on/off debug mode. When set to ``True``, stack traces
# are displayed for error pages. Should always be set to ``False`` in
# production. Best set to ``True`` in local_settings.py
DEBUG = False

# Whether a user's session cookie expires when the Web browser is closed.
SESSION_EXPIRE_AT_BROWSER_CLOSE = True

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True    (約 131列, 將False 改為 True)
.
.
try:
    from mezzanine.utils.conf import set_dynamic_settings
except ImportError:
    pass
else:
    set_dynamic_settings(globals())   #最下方加入
SECRET_KEY = "o^2ywlr-(!28f8+635em#kxugxw*"  (本列由local_settings.py複製)
 
ALLOWED_HOSTS = ["*"] 
 
STATIC_ROOT = 'static' 
 


8. 套用免費樣板(template)
8.1 選擇使用 moderna 樣版目錄複製到 your-project-name 目錄內(與manage.py同目錄內)
8.2 settings.py設定moderna
 8.2.1 設定template的工作目錄
 8.2.2 INSTALLED_APP 加入 moderna

.
.
TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [
            os.path.join(PROJECT_ROOT, "moderna/templates")
            #os.path.join(PROJECT_ROOT,"templates")
        ],
.
.
INSTALLED_APPS = (
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.redirects",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django.contrib.sitemaps",
    "django.contrib.staticfiles",
    "moderna",
    "mezzanine.boot",
    "mezzanine.conf",
.
.



9. 新增 production_settings.py, 設定 Heroku 佈署命令,儲存在
your-project-name/your-project-name/production_settings.py

# Import all default settings. 
from .settings import *

import dj_database_url
DATABASES = {
    'default': dj_database_url.config(),
}

# Static asset configuration. 
STATIC_ROOT = 'static'

# Honor the 'X-Forwarded-Proto' header for request.is_secure().
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers. 
ALLOWED_HOSTS = ['*']

# Turn off DEBUG mode.
DEBUG = False




10. 執行收集靜態檔案
python manage.py collectstatic

11. 編輯 .gitignore
要把 static 目錄下的檔案上傳,必須要.gitignore 檔案內的/static 刪除

*.pyc
*.pyo
*.db
.DS_Store
.coverage
local_settings.py
/static  刪除此行


12. 安裝 django_heroku 套件
pip install django_heroku

13. 安裝 gunicorn 套件
pip install gunicorn

14. 安裝 dj_staic 套件
pip install dj_static

15. 安裝
pip install psycopg2-binary

16. 設定初始化資料庫
python manage.py createdb

Creating default account....
username:admin
Email: leebeeru@gmail.com
passward: 1234

17. 製作需求套件的檔案
pip freeze >requirements.txt

18. 工作目錄下執行, , 本地端檢視網站是否可正常執行
python manage.py runserver

19. 執行 git 安裝git之前就開了cmd視窗,請重新開啟它。)
git init
git add . 
git commit –m “initial commit”

git config --global user.email "leebeeru@gmail.com"
git config --global user.name "leebeeru"


20. 登入 Heroku (command 視窗輸入, 會在瀏覽器開啟登入頁面)
heroku login
按下 enter 鍵
(會在瀏覽器開啟登入頁面)

點擊 login 後,回到 cmd 等待

21. 建立網站
heroku create your-project-name

22 到 heroku your-project-name設定  buildpack 到 Python



23. 設定初始化
heroku config:set DISABLE_COLLECTSTATIC=1


24. 上傳到網站
git push heroku master



25. 設定 (your-project-name修改為自己的專案名稱)
heroku config:set DJANGO_SETTINGS_MODULE=your-project-name.production_settings


26. 第一次佈署
heroku ps:scale web=1


27. 初始化資料庫
heroku run python manage.py createdb



28. 建立使用者帳號
heroku run python manage.py createsuperuser
admin 1234


29. 開啟網站 (自動開啟瀏覽器)
heroku open

30. 開啟失敗, 檢視 log 檔除錯
heroku logs


31
git add.

git commit -m "update"  (""內文字可自由更換)

git push heroku master

heroku open

Mezzanine + Heroku


宅吉便 - 有完整建置流程
Mezzanine + Heroku: 20分鐘打造你的個人部落格

科技的旅程
Heroku安裝使用教學

it邦幫忙
發布網站到 Heroku
註冊Heroku帳號、安裝 heroku CLI、Git 安裝 教學

Django學習紀錄 20.部署django至heroku平台-許永平

第 29 章 - 網站部署(使用 Heroku)

彭彭老師上傳教學
1.建立專案
2. install git工具
3.heroku heroku 註冊帳號
4. install heroku cli (command line interface)
5. heroku app

Git下載



heroku 註冊帳號 -




三文件
1. 描述使用的python 環境
runtime.txt
2.運作所需套件  requirements.txt
pip freeze >requirements.txt
3. 告訴heroku如何執行程式(process file)
Procfile

初使化專案 (第一次時執行)
git init
heroku git:remote -a 專案名稱

更新專案
git add.
git commit -m "更新訊息"   (""內文字可自由輸入)
git push heroku master





Python Django 學習紀錄(九) 部署網站到 Heroku


Nginx + uWsgi 部署 Django + Mezzanine 生产服务器 1/2
【教程】Nginx + uWsgi 部署 Django + Mezzanine 生产服务器(「自由小径」2/2


南開科大使用 Python/Django/Mezzanine所設計的新網站
智慧伴老物聯網服務中心







Python/Django 初學筆記


建立網站 老師筆記連結
[ Django ] 影片網站資料庫及後台管理(一) - 建立網站專案


Python 你好, 初次見面!! 10/26 - 11/30

頁內連結
10/26

11/09


前一陣子柯文哲說現在的學生有三種語言必學,中文、英文、還有程式語言。剛好知道有這課程的訊息.....  聽阿北的話,開始我的Python 學習, 10/26 初相見!

本篇是課後筆記, 目前的我還在摸黑進行, 只是依樣畫葫蘆, 拿香對拜跟下方連結一口令一動作的過程
http://cheng-min-i-taiwan.blogspot.com/2019/10/djangohello-app.html

1. 下載Python 程式(2019/10/26 Python 3.8.0)
     載點:  https://www.python.org/downloads/
     安裝時別忘了勾選 Add Python 3.8 to PATH

2. 安裝完成後, 從開始列裡可檢視最新安裝的 Python 程式,
     在搜尋列輸入 "cmd" -開啟command 視窗
3.  command command 視窗執行, 安裝虛擬環境
   pip install virtualenvwrapper-win

4. 測試 Python 版本
   python --version

5. 建立虛擬環境 first, 執行
  mkvirtualenv first

6.安裝Django 執行
pip install django

7..建立第一個Django專案, 執行
django-admin startproject firstproject

8.切換到專案的目錄, 執行
cd firstproject

9.用檔案管理員檢視目錄 firstproject 下有一目錄 firstproject  和檔案 manage.py
再檢視 firstproject /firstproject 內的檔案, 有4個檔案,




10.建立第一支APP, 在  users\usename\firstproject 下執行
python manage.py startapp myapp
執行結果產生目錄myapp

11.查看myapp的目錄及檔案


12.執行資料庫同步指令
python manage.py migrate

13.啟動網站
python manage.py runserver
(預設port是8000, 若在後方加上數字可更換, EX: python manage.py runserver 9000)

14. 開啟瀏覽器連結至
   127.0.0.1:8000

15. 安裝APP,使用IDLE打開settings.py

   A. 在INSALLED APPS 末端加入  'myapp',
 B. 設定 TAMPLATE 路徑   os.path.join(BASE_DIR, 'templates')
C. 設定語言繁體中文 zh-Hant
             時區 Asia/Taipei
D. 完成設定後 儲存。

16. 編輯urls.py,新增一個首頁path以及對應到的函式
 from myapp.views import sayhello
.
path('', sayhello),


17編輯 firstproject\myapp\views.py編輯sayhello函式
18. 更新網頁可見       Hello Django!


19. 網址直傳參數 (字串)
A. 編輯 urls.py 增加sayheelo2函式 路徑


B. 編輯 myapp\views.py 加入sayheelo2函式
C. 頁面執行結果
11/2 
Python Package Index  - 分享的套件包網站
ORM - Python 使用的資料庫方式不同於C使用的 my_sql
ORM - Object Relational Mapping,程式設計技術,用於實現物件導向程式語言裡不同類型系統的資料之間的轉換。 從效果上說,它其實是建立了一個可在程式語言裡使用的「虛擬物件資料庫」
物件導向 - 軟體可以像硬體一樣,做成套件包有共通性,供其它使用者使用
功能導向 - 依廠商需求製作,case by case。
python 資料型式:

今天老師範例連結

11/9 今天安裝Notepad 來編輯程式  Notepad++ 下載
今天建立 youtube 影片的網頁, 建立資料庫, 可新增刪除影片
老師筆記:

影音筆記

一、建立專案和app


mkvirtualenv youtube (建立youtube虛擬環境)
pip install django
django-admin startproject youtubeproj (建立 youtubeproj)
cd youtubeproj (進入youtubeproj 目錄)
python manage.py startapp youtubeapp (建立youtubeapp)

2. settings.py 設定
編輯 youtubeproj\youtubeproj\setting.py
...略..
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'youtubeapp', #在INSTALLED_APPS加入建立的app
...略..

.TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')], #設定templates路徑
...略..
LANGUAGE_CODE = 'zh-Hant' #設定語言 TIME_ZONE = 'Asia/Taipei' #設定時區
...略..
STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static'), ]
#設定 static 路徑


3.編輯 youtubeproj\youtubeproj\urls.py
...略..
from django.contrib import admin
from django.urls import path
from youtubeapp.views import home

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', home),
]

4. 編輯 youtubeproj\youtubeapp\views.py

from django.shortcuts import render

# Create your views here.

def home(request):
    return render(request, 'index.html', locals())

5.建立index,html程式, 置於第一階youtubeproj 目錄下建置templates 目錄 youtubeproj\templates\index.html

<!DOCTYPE html>
<html>
<head>
<title>
影片播放網站
</title>
</head>
<body>
<iframe width="560" height="315" 
 src="https://www.youtube.com/embed/W40mDCqWyYo" 
 frameborder="0" 
 allow="accelerometer; 
 autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
</iframe>
#本段由youtube 分享 -> 嵌入複製程式碼

</body>
</html>


6. youtubeproj路徑下執行

python manage.py makemigrations
python manage.py migrate
python manage.py runserver
7. 檢視網頁

二、設定影片影片大小及連結點改為變數

影片嵌入程式碼是採用iframe的標籤,其主要的參數有width, height, src。
1.修改index.html 中 iframe 中 width, height, src為變數 {{width}}、{{height}}、{{src}}
 youtubeproj\templates\index.html
<iframe width="{{width}}" height="{{height}}" 
 src="https://www.youtube.com/embed/{{src}}" 
 frameborder="0" 
 allow="accelerometer; 
 autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
</iframe>
修改iframe 中的寬、高、連結點


2. youtubeproj\youtubeapp\views.py 設定影片的寬、高和連結點
from django.shortcuts import render

# Create your views here.

def home(request):
    width=1280
    height=720
    src = 'W40mDCqWyYo'


#https://www.youtube.com/watch?v=W40mDCqWyYo複製網址中=後方的文字到src內
return render(request, 'index.html', locals())

3.啟動網站查看結果



三、建立資料庫
1. 編輯 youtubeproj\youtubeapp\models.py
from django.contrib import admin
# Register your models here.

class video(models.Model):
    name = models.CharField(max_length=50, null=False)
    width = models.IntegerField(default = 1280)
    height = models.IntegerField(default = 720)
    src = models.CharField(max_length=50, null=False)
    
    def _str_(self):
        return self.name


2.開啟admin.py撰寫註冊video資料庫到後台管理
1
2
3
4
5
6
from django.contrib import admin
from youtubeapp.models import video

# Register your models here.

admin.site.register(video)

執行下列指令, 
python manage.py makemigrations    (生成同步數據庫的代碼)
python manage.py migrate                   (同步數據庫-也就是對數據庫執行真正的遷移動作)
python manage.py createsuperuser    (建立尸superuser 帳號 admin 密碼 1234 )
python manage.py runserver

3. 127.0.0.1:8000/admin 進入後台,


4.  建立第一筆資料  Name : Django


5.編輯views.py取得一筆資料
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
from django.shortcuts import render
from youtubeapp.models import video

# Create your views here.

def home(request):
    try:
        v = video.objects.get(name="Django")
        width=v.width
        height=v.height
        src = v.src
    except:
        print("沒找到")
        width=1280
        height=720
        src = 'W40mDCqWyYo'     
    return render(request, 'index.html', locals())

6. 網頁測試執行結果 - 檢視 127.0.0.1:8000頁面



四、[ Django ] 影片網站資料庫及後台管理(四) - 讀取所有資料

1.修改views.py程式
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
from django.shortcuts import render
from youtubeapp.models import video

# Create your views here.

def home(request):
    try:
        videos = video.objects.all()
    except:
        print("沒有任何資料")
    return render(request, 'index.html', locals())

2. 修改index.html
 youtubeproj\templates\index.html
<!DOCTYPE html>
<html>
<head>
<title>
影片播放網站
</title>
</head>
<body>
{% for video in videos %}
 <iframe 
 width="{{video.width}}" 
 height="{{video.height}}" 
 src="https://www.youtube.com/embed/{{video.src}}" 
 frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
 </iframe>
{% endfor %}

</body>
</html>

每一次循環中,模板系統會渲染在 {% for %} 和 {% endfor %} 之間的所有內容。
3. 再新增一筆資料
檢視網頁, 目前有兩筆影片


五、[ Django ] 影片網站資料庫及後台管理(四) - 讀取所有資料
1. 在urls.py增加路徑
from django.contrib import admin
from django.urls import path
from youtubeapp.views import home, post

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', home),
    path('index/', home),
    path('post/', post)
]

2. views.py 新增post 函式
from django.shortcuts import render, redirect
from youtubeapp.models import video

# Create your views here.

def home(request):
    try:
        videos = video.objects.all()
    except:
        print("沒有任何資料")
    return render(request, 'index.html', locals())
def post(request): if request.method == "POST": name = request.POST["videoname"] width = int(request.POST["videowidth"]) height = int(request.POST["videoheight"]) src = request.POST["videosrc"] v = video.objects.create(name=name, width=width, height=height, src=src) v.save return redirect('/index/') return render(request, 'post.html', locals())

3. templates目錄下新增 post.html 

<!DOCTYPE html>
<html>
<head>
<title>新增一筆資料</title>
</head>
<body>
<form action="/post/" method = "POST" name = "form1">
{% csrf_token %}
<div>
名稱 : <input type="text" name="videoname" /></br>
寬度 : <input type="text" name="videowidth" /></br>
高度 : <input type="text" name="videoheight" /></br>
來源 : <input type="text" name="videosrc" /></br>
<input type="submit" name="送出資料" /></br>
</div>
</form>
</body>
</html>        

4. 啟動 post.html ( 127.0.0.1:8000/post )
5. 新增影片, 並檢視網頁, 可得三影片


六、影片網站資料庫及後台管理(六) - 表單模型化
輸入資料需要驗證,若未驗證容易引起不可遇期的問題發生。本篇文章在於使用Python程式,設計驗證表單。

1.增加驗證表單程式form.py (置於 youtubeappyoutubeapp目錄下)

1
2
3
4
5
6
from django import forms
class PostForm(forms.Form):
    name = forms.CharField(max_length=50, initial='')
    width = forms.IntegerField(max_value=1280, min_value=640)
    height = forms.IntegerField(max_value=1280, min_value=640)
    src = forms.CharField(max_length=50, initial='')

2.views.py 增加 postform 函式。
from django.shortcuts import render, redirect
from youtubeapp.models import video
from youtubeapp.form import PostForm


# Create your views here.

def home(request):
    try:
        videos = video.objects.all()
    except:
        print("沒有任何資料")
    return render(request, 'index.html', locals())
    
def post(request):
    if request.method == "POST":
        name = request.POST["videoname"]
        width = int(request.POST["videowidth"])
        height = int(request.POST["videoheight"])
        src = request.POST["videosrc"]
        v = video.objects.create(name=name, width=width, height=height, src=src)
        v.save
        return redirect('/index/')
    return render(request, 'post.html', locals())

def postform(request):
    postform = PostForm()
    return render(request, "postform.html", locals())        


3. 增加路徑 urls.py 
from django.contrib import admin
from django.urls import path
from youtubeapp.views import home, post, postform

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',home),
    path('index/', home),
    path('post/', post),
    path('postform/', postform),
] 


4. 製作驗證表單 postform.html
<form action="." method="POST" name="form1">
  {% csrf_token%}
 {{postform}}        
</form>


5. 開啟網頁檢視

6. 右鍵 - 檢查 
 檢視原始碼

(七) - 新增影片並驗證width, height 只能輸入數字
加入下方連結影片, 並使用驗證表單。

1. 新增 post2.html 
<!DOCTYPE html>
<html>
<head>
<title>資料新增並驗證</title>
</head>
<body>
<form action="." method="POST" name="form1">
 {% csrf_token%}
 <table border="1" cellspacing="1" ncellpadding="4">
  <tr><th>影片名稱</th><td>{{postform.name}}</td></tr>
  <tr><th>影片寬度</th><td>{{postform.width}}</td></tr>
  <tr><th>影片高度</th><td>{{postform.height}}</td></tr>
  <tr><th>影片來源</th><td>{{postform.src}}</td></tr>
 </table>
 <input type="submit"  name="button1" id="button1" value="送出"/>
 <input type="reset"  name="button2" id="button2" value="重置"/>
</form>
</body>
</html> 


2. urls.py 加入post2 路徑
from django.contrib import admin
from django.urls import path
from youtubeapp.views import home, post, postform, post2

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',home),
    path('index/', home),
    path('post/', post),
    path('postform/', postform),
    path('post2/', post2),
]


3. views.py 加入post2 路徑
....略....
def postform(request):
    postform = PostForm()
    return render(request, "postform.html", locals())
    
def post2(request):
    if request.method == "POST":
        postform = PostForm(request.POST)
        if postform.is_valid():
            name = postform.cleaned_data["name"]
            width = int(postform.cleaned_data["width"])
            height = int(postform.cleaned_data["height"])
            src = postform.cleaned_data["src"]
            v = video.objects.create(name=name, width=width, height=height, src=src)
            v.save
            return redirect('/index/')
        else:
            print("證驗有誤")
    else:
        postform = PostForm()
    return render(request, 'post2.html', locals())


4. 測試頁面-影片寬度和高度只能輸入數字, 執行加入
5. 開啟網頁檢視

八、影片網站資料庫及後台管理 - 用下拉式選單的方式, 刪除資料
1.新增 delete.html
<!DOCTYPE html>
<html>
<head>
<title>刪除資料</title>
</head>
<body>
<h1>刪除資料</h1>
<form action="." method="POST" name="form1">
 {% csrf_token%}
 請輸入欲刪除的影片名稱: 
 <select name="videoname"> 
 {% for video in videos %}
  <option value="{{video.name}}">{{video.name}}</option>
 {% endfor %} 
 </select>
 <input type="submit"  name="button" id="button" value="確定刪除"/>
 
</form>
</body>
</html>  


2. urls.py 加入 delete delete 路徑
from django.contrib import admin
from django.urls import path
from youtubeapp.views import home, post, postform, post2, delete

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',home),
    path('index/', home),
    path('post/', post),
    path('postform/', postform),
    path('post2/', post2),
    path('delete/', delete),
]


3. views.py 下方加入delete 函式
....略....

    
def delete(request):
    if request.method == "POST":
        videoname=request.POST['videoname']
    try:
        v = video.objects.get(name=videoname)
        v.delete()
        return redirect('/index/')
    except:
        print("讀取錯誤")
    try:
        videos = video.objects.all()
    except:
        print("沒有任何資料")
    return render(request, "delete.html", locals())