Code

Ticket #13814: 13814.diff

File 13814.diff, 676 bytes (added by yuval_a, 4 years ago)

Proposed utility method

Line 
1### Eclipse Workspace Patch 1.0
2#P django-trunk
3Index: django/contrib/sites/models.py
4===================================================================
5--- django/contrib/sites/models.py      (revision 13418)
6+++ django/contrib/sites/models.py      (working copy)
7@@ -23,6 +23,13 @@
8             SITE_CACHE[sid] = current_site
9         return current_site
10 
11+    def get_current_or_request(self, request):
12+        if Site._meta.installed:
13+            site = Site.objects.get_current()
14+        else:
15+            site = RequestSite(request)
16+        return site
17+
18     def clear_cache(self):
19         """Clears the ``Site`` object cache."""
20         global SITE_CACHE