#19698 closed Bug (fixed)
Deleting Sites through a manager does not clear cache
Reported by: | 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 )
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)
Attachments (4)
Change History (10)
comment:1 by , 12 years ago
Description: | modified (diff) |
---|
comment:2 by , 12 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 12 years ago
Attachment: | 19698-2.patch added |
---|
Refactored the previous patch as Site no longer needed a save() method either.
by , 12 years ago
Attachment: | 19698-3.patch added |
---|
Sorry, forgot to take out decorator on previous patch.
by , 12 years ago
Attachment: | 19698-rebase-and-cleaned.diff added |
---|
comment:3 by , 12 years ago
Cc: | added |
---|---|
Has patch: | set |
Triage Stage: | Accepted → Ready for checkin |
Version: | 1.4 → 1.5-rc-1 |
Hi;
I've rebased the patch, checked and fixed some pep8 violations.
I've also moved the function to the end of the file, instead of writing in after the class Site.
The patch is ready for checking. I've also changed the version to 1.5-rc1, because it is a bug. If you don't agree, you can change it.
This is my first work in Django trac, so sorry if I did something wrong :) Thanks for your help, any comments are appreciated.
comment:4 by , 12 years ago
Version: | 1.5-rc-1 → 1.4 |
---|
You can't mark your own patches as Ready For Check-in and version is used for when the bug was identified. Otherwise the patch looks fine! Leaving as RFC.
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
The
delete()
method of theSite
class should probably be replaced by apre_delete
signal.