from django.conf import settings

from .models import SiteSetting


def get_site_settings_and_add_to_request(request):
    settings_id = getattr(settings, 'SITE_SETTINGS_ID', None)
    try:
        site_settings = SiteSetting.objects.get(id=settings_id)
    except SiteSetting.DoesNotExist:
        site_settings = None
    request.site_settings = site_settings
    return site_settings


def get_site_settings_uncached(site_id=None):
    return SiteSetting.objects.get(pk=site_id)

@@ -86,42 +86,130 @@
 ings
-_and_add_to_request(request):%0A    
+(request):%0A    if hasattr(request, 'site_settings'):%0A        site_settings = request.site_settings%0A    else:%0A        site_
 sett
@@ -262,16 +262,20 @@
 , None)%0A
+    
     try:
@@ -275,16 +275,20 @@
    try:%0A
+    
         
@@ -307,35 +307,40 @@
 s = 
-SiteS
+get_site_s
 etting
-.objects.get(id=
+s_uncached(site_
 sett
@@ -352,16 +352,20 @@
 id)%0A    
+    
 except S
@@ -389,32 +389,36 @@
 tExist:%0A        
+    
 site_settings = 
@@ -422,16 +422,20 @@
  = None%0A
+    
     requ

Rewrite get_site_settings_function