Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django在localhost之后追加域名_Python_Django_Ubuntu_Nginx - Fatal编程技术网

Python Django在localhost之后追加域名

Python Django在localhost之后追加域名,python,django,ubuntu,nginx,Python,Django,Ubuntu,Nginx,我创建了一个django项目。当我启动服务器并打开127.0.0.1:8000/admin时。我重定向到 http://127.0.0.1:8000/www.pxxx-xxxx.com/order/success/admin/ 然后django显示错误“ 找不到页面(404) 为什么django在127.0.0.1:8000之后追加url(www.pxxx-xxxx.com/order/success/) 这是我的当前设置.py: import os # Build paths inside

我创建了一个django项目。当我启动服务器并打开127.0.0.1:8000/admin时。我重定向到

http://127.0.0.1:8000/www.pxxx-xxxx.com/order/success/admin/
然后django显示错误“

找不到页面(404)

为什么django在127.0.0.1:8000之后追加url(www.pxxx-xxxx.com/order/success/)

这是我的当前设置.py:

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.abspath(
    os.path.join(
        os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
        ".."
    )
)


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']

# SECURITY WARNING: don't run with debug turned on in production!

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'contact',
    'festival',
    'uploads',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'project_name.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'project_name.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.environ['DBNAME'],
        'PASSWORD' : os.environ['DBPASS'],
        'USER' : os.environ['DBUSER'],
        'HOST': os.environ.get('DBHOST', None)
    }
}


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/


STATIC_URL = '/static/'

STATIC_ROOT = os.environ['STATIC_ROOT']

MEDIA_URL = '/media/'

MEDIA_ROOT = os.environ['MEDIA_ROOT']

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]
下面是my urls.py的外观:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('website.urls', namespace='website')),
]

提前感谢

您能提供url.py?和settings.py吗?欢迎这样做,请阅读。不要忘记提供一些代码,并使用.add route到func def@app.route('/webhook',methods=['POST'])def webhook()正确格式化您的问题:我发布了我的settings.py和url.py。请选中在chrome中打开一个匿名窗口,然后尝试提供url.py?和settings.py?欢迎这样做,请阅读。不要忘记提供一些代码,并使用.add route到func def@app.route('/webhook',methods=['POST'])def webhook正确格式化您的问题():我发布了我的settings.py和url.py。请选中在chrome中打开一个匿名窗口,然后重试