diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py
index fb6d0a2..c928a4e 100644
a
|
b
|
class Site(models.Model):
|
44 | 44 | def __unicode__(self): |
45 | 45 | return self.domain |
46 | 46 | |
| 47 | def delete(self): |
| 48 | pk = self.pk |
| 49 | super(Site, self).delete() |
| 50 | try: |
| 51 | del(SITE_CACHE[pk]) |
| 52 | except KeyError: |
| 53 | pass |
| 54 | |
| 55 | |
47 | 56 | class RequestSite(object): |
48 | 57 | """ |
49 | 58 | A class that shares the primary interface of Site (i.e., it has |
diff --git a/django/contrib/sites/tests.py b/django/contrib/sites/tests.py
new file mode 100644
index 0000000..d2ec331
-
|
+
|
|
| 1 | """ |
| 2 | >>> # Make sure that get_current() does not return a deleted Site object. |
| 3 | >>> from django.contrib.sites.models import Site |
| 4 | >>> s = Site.objects.get_current() |
| 5 | >>> s |
| 6 | <Site: example.com> |
| 7 | |
| 8 | >>> s.delete() |
| 9 | >>> Site.objects.get_current() |
| 10 | Traceback (most recent call last): |
| 11 | ... |
| 12 | DoesNotExist: Site matching query does not exist. |
| 13 | """ |