Skip to content

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

Use Django Sites framework

Patryk Zawadzkica0b18e1214f
diff --git a/app.json b/app.json
index f1f30c3b17..1796fd3120 100644
--- a/app.json
+++ b/app.json
@@ -18,11 +18,6 @@
"description": "A secret key for verifying the integrity of signed cookies.",
"generator": "secret"
},
- "FQDN": {
- "description": "Fully qualified domain name for linking back to your app.",
- "value": "",
- "required": false
- },
"AWS_MEDIA_BUCKET_NAME": {
"description": "If you intend to upload your own product images, we strongly recommend configure S3.",
"value": "",
diff --git a/saleor/core/context_processors.py b/saleor/core/context_processors.py
index 57dcb7d298..126bc7bca7 100644
--- a/saleor/core/context_processors.py
+++ b/saleor/core/context_processors.py
@@ -11,10 +11,6 @@ def get_setting_as_dict(name, short_name=None):
return {}
-def canonical_hostname(request):
- return get_setting_as_dict('FQDN')
-
-
def default_currency(request):
return get_setting_as_dict('DEFAULT_CURRENCY')
diff --git a/saleor/core/utils/__init__.py b/saleor/core/utils/__init__.py
index a6fedb7c70..5166bf969e 100644
--- a/saleor/core/utils/__init__.py
+++ b/saleor/core/utils/__init__.py
@@ -4,6 +4,7 @@ import re
from django import forms
from django.conf import settings
+from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.template.response import TemplateResponse
from django.utils.encoding import iri_to_uri, smart_text
@@ -76,11 +77,8 @@ class BaseStep(Step):
def build_absolute_uri(location, is_secure=False):
- try:
- host = settings.FQDN
- except AttributeError:
- raise ImproperlyConfigured('You need to specify FQDN in '
- 'your Django settings file')
+ site = Site.objects.get_current()
+ host = site.domain
if not absolute_http_url_re.match(location):
current_uri = '%s://%s' % ('https' if is_secure else 'http', host)
location = urljoin(current_uri, location)
diff --git a/saleor/settings.py b/saleor/settings.py
index 466a8845bb..9f9a943b87 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -67,7 +67,6 @@ context_processors = [
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.request',
- 'saleor.core.context_processors.canonical_hostname',
'saleor.core.context_processors.default_currency',
'saleor.core.context_processors.categories']
@@ -198,9 +197,6 @@ AUTHENTICATION_BACKENDS = (
AUTH_USER_MODEL = 'userprofile.User'
-# Fully qualified domain name
-FQDN = os.environ.get('FQDN', 'localhost:8000')
-
LOGIN_URL = '/account/login'
WARN_ABOUT_INVALID_HTML5_OUTPUT = False
@@ -225,8 +221,6 @@ PAYMENT_VARIANTS = {
'default': ('payments.dummy.DummyProvider', {})
}
-PAYMENT_HOST = FQDN
-
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer'
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'