【问题标题】:Django Admin 403 - Forbidden: Access is denied IISDjango Admin 403 - 禁止:访问被拒绝 IIS
【发布时间】:2021-05-10 02:10:02
【问题描述】:

首先我为我糟糕的英语道歉。

我是不是把django项目上传到windows服务器,但是我从管理面板添加数据时,得到的结果如下。

"403 - 禁止访问:访问被拒绝。 您无权使用您提供的凭据查看此目录或页面。”

Settings.py

from pathlib import Path
import os

BASE_DIR = Path(__file__).resolve().parent.parent




DEBUG = False

ALLOWED_HOSTS = ['*']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    "home",
    'django.contrib.sitemaps'
]

MIDDLEWARE = [
    
    'htmlmin.middleware.HtmlMinifyMiddleware',
    'htmlmin.middleware.MarkRequestMiddleware',
    '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 = 'umy.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 = 'umy.wsgi.application'



DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}


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',
    },
]


LANGUAGE_CODE = 'tr'

TIME_ZONE = 'Europe/Istanbul'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

#STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

web.config

<?xml version="1.0" encoding="utf-8"?>

<configuration>
  <system.webServer>
  
    <handlers>
      <add name="Python FastGCI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="c:\python39\python.exe|c:\python39\lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
    </handlers>
        <httpErrors errorMode="DetailedLocalOnly" />
  </system.webServer>
  <appSettings>
    <add key="WSGI_HANDLER" value="umy.wsgi.application" />
    <add key="DJANGO_SETTINGS_MODULE" value="umy.settings" />
    <add key="PYTHONPATH" value="C:\Inetpub\vhosts\domain.com\httpdocs" />
  </appSettings>
</configuration>

它记录到数据库,但这是我在返回路径上遇到的错误

谢谢

【问题讨论】:

    标签: python django http-status-code-403


    【解决方案1】:

    不确定您是否已经解决了该问题。我遇到了同样的问题,并按照此处https://github.com/az-09/deploy-api-app-iis 中的步骤从头开始添加了一个新站点。然后它起作用了。请告诉我进展如何。

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。
    • 虽然此链接可能会回答问题,但最好在此处包含答案的基本部分并提供链接以供参考。如果链接页面发生更改,仅链接答案可能会失效。 - From Review
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-23
    • 1970-01-01
    相关资源
    最近更新 更多