Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 如何修复不在“”中的错误_Django - Fatal编程技术网

Django 如何修复不在“”中的错误

Django 如何修复不在“”中的错误,django,Django,我在用postgresql 如果我删除一个不在的学校,它会运行良好 cursor.execute('create temp table paso as(SELECT b.username as user__username ,count(a.name) as tot FROM principal_student a join users_user b ON a.user_id = b.id join principal_cycle c ON c.id = a.cycle_id WHERE a

我在用postgresql

如果我删除一个不在的学校,它会运行良好

cursor.execute('create temp table paso as(SELECT b.username as user__username ,count(a.name) as tot FROM principal_student a join users_user b ON  a.user_id = b.id join principal_cycle c ON c.id = a.cycle_id 
WHERE a.school not in ("student not It has school age","You do not have school age") AND (c.status=true) group by a.name,b.username order by b.username)');

cursor.execute('Select a.user__username,count(a.tot) from paso a group by user__username order by total desc')

        columns = [column[0] for column in cursor.description]
        results = []
        for row in cursor.fetchall():
            results.append(dict(zip(columns,row)))

        context['prod'] = results       
        cursor.close()   

您在哪个cursor.execute上遇到的错误是什么?不清楚我们调试的是什么。列student not It has school age不存在尝试输入“student not It has school age”并遵循debugAre字段,如“user\uuuuu username”是否真实?这看起来更像是外键的Django ORM符号。不管怎样,为什么要用原始sql来完成django这样的简单任务?这只是一个as,错误在引号中,但不像用where a.school编写select,而不是在“xxx”、“xxx”中。你知道如何翻译这个select orm create temp table paso asSELECT b.username作为user\uuu username,counta.name作为tot来自校长学生a join users\u用户b ON a.user\u id=b.id join principal\u cycle c ON c.id=a.cycle\u id其中a.school不在学生中没有学龄,你没有学龄,c.status=true按a.name分组,b、 用户名按b.username'排序;