diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py
index e22fd40..7ee7e09 100644
a
|
b
|
class SiteManager(models.Manager):
|
78 | 78 | global SITE_CACHE |
79 | 79 | SITE_CACHE = {} |
80 | 80 | |
| 81 | def get_by_natural_key(self, domain): |
| 82 | return self.get(domain=domain) |
| 83 | |
81 | 84 | |
82 | 85 | @python_2_unicode_compatible |
83 | 86 | class Site(models.Model): |
… |
… |
class Site(models.Model):
|
96 | 99 | def __str__(self): |
97 | 100 | return self.domain |
98 | 101 | |
| 102 | def natural_key(self): |
| 103 | return (self.domain,) |
| 104 | |
99 | 105 | |
100 | 106 | def clear_site_cache(sender, **kwargs): |
101 | 107 | """ |
diff --git a/docs/releases/1.10.txt b/docs/releases/1.10.txt
index 4f6ff55..18fc4a8 100644
a
|
b
|
Minor features
|
93 | 93 | :mod:`django.contrib.sites` |
94 | 94 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
95 | 95 | |
96 | | * ... |
| 96 | * The ``django.contrib.sites.models.Site`` model now supports |
| 97 | :ref:`natural keys <topics-serialization-natural-keys>`. |
97 | 98 | |
98 | 99 | :mod:`django.contrib.staticfiles` |
99 | 100 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
diff --git a/tests/sites_tests/tests.py b/tests/sites_tests/tests.py
index a5ce7a6..6bf7ce4 100644
a
|
b
|
class SitesFrameworkTests(TestCase):
|
179 | 179 | with self.assertRaisesMessage(ValidationError, msg): |
180 | 180 | site.validate_unique() |
181 | 181 | |
| 182 | def test_site_natural_key(self): |
| 183 | self.assertEqual(Site.objects.get_by_natural_key(self.site.domain), self.site) |
| 184 | self.assertEqual(self.site.natural_key(), (self.site.domain,)) |
| 185 | |
182 | 186 | |
183 | 187 | class JustOtherRouter(object): |
184 | 188 | def allow_migrate(self, db, app_label, **hints): |