Ticket #9228: sites2.diff

File sites2.diff, 1.3 KB (added by Boo, 16 years ago)

Patch v.2

  • django/contrib/sites/tests.py

     
    33>>> from django.conf import settings
    44>>> Site(id=settings.SITE_ID, domain="example.com", name="example.com").save()
    55
     6>>> # Make sure that save() remove the relevant key from the SITE_CACHE dictionary.
     7>>> s = Site.objects.get_current()
     8>>> isinstance(s, Site)
     9True
     10
     11>>> s.domain = "example2.com"
     12>>> s.name = "example2.com"
     13>>> s.save()
     14>>> s = Site.objects.get_current()
     15>>> s.domain
     16'example2.com'
     17
     18>>> s.name
     19'example2.com'
     20
    621>>> # Make sure that get_current() does not return a deleted Site object.
    722>>> s = Site.objects.get_current()
    823>>> isinstance(s, Site)
  • django/contrib/sites/models.py

     
    4242    def __unicode__(self):
    4343        return self.domain
    4444   
     45    def save(self, force_insert=False, force_update=False):
     46        super(Site, self).save(force_insert, force_update)
     47        del SITE_CACHE[self.pk]
     48
    4549    def delete(self):
    4650        pk = self.pk
    4751        super(Site, self).delete()
Back to Top