def clear_site_cache(sender, **kwargs):
 instance = kwargs['instance']
 using = kwargs['using']
 try:
  del SITE_CACHE[instance.pk]
 except KeyError:
  pass
 try:
  del SITE_CACHE[Site.objects.using(using).get(pk=instance.pk).domain]
 except (KeyError, Site.DoesNotExist):
  pass

def clear_site_cache ( sender , ** kwargs ) : instance = kwargs [ 'instance' ] using = kwargs [ 'using' ] try : del SITE_CACHE [ instance . pk ] except KeyError : pass try : del SITE_CACHE [ Site . objects . using ( using ) . get ( pk = instance . pk ) . domain ] except ( KeyError , Site . DoesNotExist ) : pass
clears the cache each time a site is saved or deleted .