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")