WIP: fixing base_url
This commit is contained in:
parent
bbefbea939
commit
af9b1f0c5d
@ -27,6 +27,9 @@ DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
# Set up your website base URL here, WITHOUT A TRAILING SLASH.
|
||||
BASE_URL = "http://localhost:8000"
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
|
@ -16,8 +16,12 @@ Including another URLconf
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
from django.conf.urls import include, url
|
||||
from django.conf import settings
|
||||
import urllib.parse
|
||||
base_path = urllib.parse.urlparse(settings.BASE_URL).path[1:]
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
url(r'', include('web.urls')),
|
||||
path(base_path+'/admin/', admin.site.urls),
|
||||
url(base_path+'/' if base_path else '', include('web.urls')),
|
||||
]
|
||||
|
@ -1,16 +1,9 @@
|
||||
from django.conf import settings
|
||||
import urllib.parse
|
||||
|
||||
def BASE_URL(request):
|
||||
"""
|
||||
Return a BASE_URL template context for the current request.
|
||||
"""
|
||||
if request.is_secure():
|
||||
scheme = 'https://'
|
||||
else:
|
||||
scheme = 'http://'
|
||||
fullhost = request.get_host()
|
||||
host = fullhost.split(":")[0]
|
||||
port = request.get_port()
|
||||
if port == 80 or port == 443:
|
||||
base = host
|
||||
else:
|
||||
base = host+":"+port
|
||||
return {'BASE_URL': scheme + base, }
|
||||
parse = urllib.parse.urlparse(settings.BASE_URL)
|
||||
return {'BASE_URL': parse.scheme+"://"+parse.netloc, }
|
Loading…
Reference in New Issue
Block a user