Changes between Initial Version and Version 1 of Ticket #30072


Ignore:
Timestamp:
Jan 3, 2019, 4:17:51 AM (6 years ago)
Author:
Luke Seelenbinder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #30072 – Description

    initial v1  
    22
    33I would patch it to use the Django caching system instead of a global, but I'm not sure if that's the correct way to go about it.
     4
     5Relevant code: https://github.com/django/django/blob/master/django/contrib/sites/models.py#L103
     6
     7
     8{{{
     9#!python
     10def clear_site_cache(sender, **kwargs):
     11    """
     12    Clear the cache (if primed) each time a site is saved or deleted.
     13    """
     14    instance = kwargs['instance']
     15    using = kwargs['using']
     16    try:
     17        del SITE_CACHE[instance.pk]
     18    except KeyError:
     19        pass
     20    try:
     21        del SITE_CACHE[Site.objects.using(using).get(pk=instance.pk).domain]
     22    except (KeyError, Site.DoesNotExist):
     23        pass
     24}}}
     25
Back to Top