From 5e321ad42074a939a9ee7d8f8aa7329404e810ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 17 Aug 2020 09:29:03 +0800 Subject: [PATCH] Added to catch ProgrammingError when checking whether a user is in use in the Mia core application. --- mia_core/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mia_core/models.py b/mia_core/models.py index deefa18..755260c 100644 --- a/mia_core/models.py +++ b/mia_core/models.py @@ -22,7 +22,8 @@ import hashlib from dirtyfields import DirtyFieldsMixin from django.conf import settings -from django.db import models, connection, OperationalError, transaction +from django.db import models, connection, OperationalError, transaction, \ + ProgrammingError from django.db.models.functions import Now from django.urls import reverse @@ -185,6 +186,8 @@ class User(DirtyFieldsMixin, models.Model): cursor.execute(sql, [self.pk, self.pk]) except OperationalError: return False + except ProgrammingError: + return False if cursor.fetchone() is None: return False return True