from django.utils.deprecation import MiddlewareMixin class SSHConnectionMiddleware(MiddlewareMixin): _connection_checked = False # Sınıf değişkeni olarak tanımla def process_request(self, request): # Sadece bir kez çalıştır if not SSHConnectionMiddleware._connection_checked: from .apps import check_server_connection check_server_connection() SSHConnectionMiddleware._connection_checked = True