Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use CANONICAL_HOSTNAME instead of sites
Michal Ociepkaf193994942f2
diff --git a/saleor/settings.py b/saleor/settings.pyindex 8ca038e015..120350cb5c 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -160,6 +160,8 @@ AUTHENTICATION_BACKENDS = (AUTH_USER_MODEL = 'userprofile.User'+CANONICAL_HOSTNAME = 'localhost:8000'+EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'WARN_ABOUT_INVALID_HTML5_OUTPUT = Falsediff --git a/saleor/utils.py b/saleor/utils.pyindex 1ea4864327..4a50eb1d87 100644--- a/saleor/utils.py+++ b/saleor/utils.py@@ -1,12 +1,16 @@# coding: utf-8from django import forms+from django.conf import settings+from django.core.exceptions import ImproperlyConfigured+from django.http.request import absolute_http_url_refrom django.template.response import TemplateResponse-from satchless.process import Step-from satchless.process import InvalidData+from django.utils.encoding import iri_to_uri+from satchless.process import InvalidData, Step+from urlparse import urljoin-__all__ = ['BaseStep', 'CategoryChoiceField']+__all__ = ['BaseStep', 'CategoryChoiceField', 'build_absolute_uri']class CategoryChoiceField(forms.ModelChoiceField):@@ -64,3 +68,15 @@ class BaseStep(Step):def get_absolute_url(self):raise NotImplementedError()+++def build_absolute_uri(location, is_secure=False):+ try:+ host = settings.CANONICAL_HOSTNAME+ except AttributeError:+ raise ImproperlyConfigured('You need to specify CANONICAL_HOSTNAME in '+ 'your Django settings file')+ if not absolute_http_url_re.match(location):+ current_uri = '%s://%s' % ('https' if is_secure else 'http', host)+ location = urljoin(current_uri, location)+ return iri_to_uri(location)