diff --git a/authentik/core/models.py b/authentik/core/models.py index 136db1c14..33508aac8 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -278,7 +278,13 @@ class Application(PolicyBindingModel): """Get casted provider instance""" if not self.provider: return None - return Provider.objects.get_subclass(pk=self.provider.pk) + # if the Application class has been cache, self.provider is set + # but doing a direct query lookup will fail. + # In that case, just return None + try: + return Provider.objects.get_subclass(pk=self.provider.pk) + except Provider.DoesNotExist: + return None def __str__(self): return self.name