[問題] django CVB CRUD
Django
最近在把從FVB改成CVB
有關資料庫 沒有使用正規modelform 完成CRUD
練習一個一個html <tr> <td>
URL:path('aaa/',Flycargo_totals.as_view())
當link aaa時 想從資料庫讀資料並顯示在aaa上
一直發生try不到資料而啟動except
當我把units 讀取資料庫.objects.all()給刪除
就可以顯示正常aaa.html 但沒有資料庫資料壓?
請問哪邊有錯誤?
Q1.CVB 已經在判斷get / post分類而不要在try/except資料庫?
Q2.WHY?
已經卡關兩天..
謝謝回覆
class Flycargo_totala(View):
def get(self, request):
try:
units = Flycargo_total_model.objects.all()
x = units
time = datetime.now()
# context = locals()
# for x in units:
# context['t_code_name'] = x.m_code_name
# context['t_company_name'] = x.m_company_name
# context['t_first_date'] = x.m_first_day
# context['t_last_date'] = x.m_last_day
# context['t_ship_days'] = x.m_ship_day
return render(request, 'flycargo_total.html', locals())
except:
units = "讀取錯誤"
print("========nook")
return HttpResponse("no ok")
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.228.127.110 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1601920522.A.E93.html
推
10/06 08:12,
4年前
, 1F
10/06 08:12, 1F
※ 編輯: jackjenny (36.228.127.110 臺灣), 10/06/2020 13:34:32
→
10/06 15:28,
4年前
, 2F
10/06 15:28, 2F
推
10/06 16:14,
4年前
, 3F
10/06 16:14, 3F
→
10/06 19:17,
4年前
, 4F
10/06 19:17, 4F
→
10/06 19:49,
4年前
, 5F
10/06 19:49, 5F
→
10/06 19:52,
4年前
, 6F
10/06 19:52, 6F
→
10/06 19:54,
4年前
, 7F
10/06 19:54, 7F
Python 近期熱門文章
PTT數位生活區 即時熱門文章