Opened 12 years ago

Last modified 10 years ago

#19698 closed Bug

Deleting Sites through a manager does not clear cache — at Version 1

Reported by: ddavies@… Owned by: nobody
Component: contrib.sites Version: 1.4
Severity: Normal Keywords:
Cc: Serdar Dalgic Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Claude Paroz)

When you delete a Site instance, i.e. Site.objects.get_current().delete(), the cache is cleared. However, if you delete all sites, Site.objects.all().delete(), the cache is not cleared.

    def test_delete_all_sites_clears_cache(self):
        """
        When all site objects are deleted the cache should  also
        be cleared and get_current should raise a DoesNotExist
        """
        from django.contrib.sites.models import Site
        site = Site.objects.create(domain='example.com', name='test')
        self.assertIsInstance(Site.objects.get_current(), Site)
        Site.objects.all().delete()
        self.assertRaises(Site.DoesNotExist, Site.objects.get_current)

Change History (1)

comment:1 by Claude Paroz, 12 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top