Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use SiteSettings instead of Site

Krzysztof Wolski2ab636daf13d
diff --git a/saleor/core/utils/__init__.py b/saleor/core/utils/__init__.py
index 9d47eee64b..940c3313be 100644
--- a/saleor/core/utils/__init__.py
+++ b/saleor/core/utils/__init__.py
@@ -15,6 +15,7 @@ from geolite2 import geolite2
from prices import PriceRange
from ...userprofile.models import User
+from ...site.utils import get_site_settings
try:
from urllib.parse import urljoin
@@ -40,8 +41,7 @@ class CategoryChoiceField(forms.ModelChoiceField):
def build_absolute_uri(location, is_secure=False):
- from django.contrib.sites.models import Site
- site = Site.objects.get_current()
+ site = get_site_settings()
host = site.domain
current_uri = '%s://%s' % ('https' if is_secure else 'http', host)
location = urljoin(current_uri, location)
diff --git a/saleor/product/views.py b/saleor/product/views.py
index 3a861fcc22..a6c56340cc 100644
--- a/saleor/product/views.py
+++ b/saleor/product/views.py
@@ -80,6 +80,8 @@ def product_details(request, slug, product_id, form=None):
def product_add_to_cart(request, slug, product_id):
+ # types: (int, str, dict) -> None
+
if not request.method == 'POST':
return redirect(reverse(
'product:details',
diff --git a/tests/test_data_feeds.py b/tests/test_data_feeds.py
index ab853beb73..e1a95b5051 100644
--- a/tests/test_data_feeds.py
+++ b/tests/test_data_feeds.py
@@ -4,7 +4,6 @@ import csv
from mock import Mock
-from django.contrib.sites.models import Site
from django.utils import six
from django.utils.encoding import smart_text
if six.PY3:
@@ -17,6 +16,7 @@ from saleor.data_feeds.google_merchant import (get_feed_items,
item_attributes,
item_google_product_category,
write_feed)
+from saleor.site.utils import get_site_settings
def test_saleor_feed_items(product_in_stock):
@@ -27,7 +27,7 @@ def test_saleor_feed_items(product_in_stock):
discounts = []
category_paths = {}
attributes_dict = {}
- current_site = Site.objects.get_current()
+ current_site = get_site_settings()
attribute_values_dict = {smart_text(a.pk): smart_text(a) for a
in AttributeChoiceValue.objects.all()}
attributes = item_attributes(items[0], categories, category_paths,