TypeError at /train/check_gw/
compile() takes 2 positional arguments but 3 were given
Request Method: GET
Request URL: http://127.0.0.1:8000/train/check_gw/
Django Version: 3.1.6
Exception Type: TypeError
Exception Value:
compile() takes 2 positional arguments but 3 were given
Exception Location: D:\JCHEN\python\project\mydjango\sql_server\pyodbc\compiler.py, line 357, in compile
Python Executable: D:\JCHEN\python\project\mydjango\venv\Scripts\python.exe
Python Version: 3.9.0
Python Path:
['D:\\JCHEN\\python\\project\\mydjango',
'D:\\JCHEN\\python\\project\\mydjango',
'2020.2.3\\plugins\\python\\helpers\\pycharm_display',
'E:\\Program Files\\Python39\\python39.zip',
'E:\\Program Files\\Python39\\DLLs',
'E:\\Program Files\\Python39\\lib',
'E:\\Program Files\\Python39',
'D:\\JCHEN\\python\\project\\mydjango\\venv',
'D:\\JCHEN\\python\\project\\mydjango\\venv\\lib\\site-packages',
'2020.2.3\\plugins\\python\\helpers\\pycharm_matplotlib_backend']
Server time: Thu, 13 May 2021 07:20:07 +0000
Error during template rendering
In template D:\JCHEN\python\project\mydjango\train\templates\gw_list.html, error at line 10
compile() takes 2 positional arguments but 3 were given
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>{{ title }}</title>
6 </head>
7 <body>
8 <h3>{{ title }}</h3>
9 <table>
10 {% for i in gangwei_list %} #提示這行代碼出錯了
11
12
13 <tr>
14 <th>{{ i.daihao }}</th>
15 <th>{{ i.gangwei }}</th>
16 </tr>
17 {% endfor %}
18 </table>
19 <br>
20 {% if is_paginated %}
urls.py
from django.urls import path
from . import views
from . views import check_gw
urlpatterns = [
path('check_gw/', check_gw.as_view(), name='check_gw'),
models.py
from django.db import models
class gangwei(models.Model):
daihao = models.CharField(max_length=5)
gangwei = models.CharField(max_length=30)
pth_file = models.CharField(max_length=60)
rev = models.CharField(max_length=30)
lasttime = models.DateTimeField(blank=True, null=True)
class Meta:
managed = False
db_table = 'gangwei'
views.py
class check_gw(ListView):
model = gangwei
template_name = 'gw_list.html'
extra_context = {'title':'能力串列目錄'}
queryset = gangwei.objects.all()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/283891.html
下一篇:python課題設計
