I'm trying to find a way to handle on admin logout (django admin page), files in a certain folder will get deleted. Because i have a function on certain admin interactions, files will get saved to a folder and i would like these files to get deleted when the admin logging out of the admin page.
I only know about Django detect user logout on browser close like so:
if settings.SESSION_EXPIRE_AT_BROWSER_CLOSE:
What i would like to do is to override the logout function of admin site to execute a function and delete files in a folder. I can see that the logout function exists in https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L349 but how do i override it and add my delete files function into it ?