问题描述
我正在 pythonanywhere 上部署 python django 网站。我在项目中的静态文件和设置中添加了 favicon.ico,并在运行我看到的 Web 应用程序后添加了
**Not Found**
The requested resource was not found on this server.
2021-06-19 04:39:55,391: Not Found: /favicon.ico
2021-06-19 04:42:25,484: Not Found: /
2021-06-19 06:03:44,307: Not Found: /
2021-06-19 06:04:05,420: Not Found: /
path( "favicon.ico",RedirectView.as_view(url=staticfiles_storage.url("favicon.ico")))
header.html :
<link rel="icon" type="image/x-icon" href="{% static 'favicon.ico' %}">
并安装 django-favicon 包。
我该如何摆脱它?
这是 settings.py :
import os from pathlib import Path
import smtplib
BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY=""
# Security WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = [
'*','namitatare.pythonanywhere.com'
]
# Application deFinition
INSTALLED_APPS = [
'django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','KPECcontactApp','CareerApp','InvestorsApp','ServicesApp','ConsultantApp',]
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 = 'KPECproject.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates','Dirs': [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 = 'KPECproject.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3','NAME': str(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 = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # new
EMAIL_KPEC='kpecengineers@gmail.com'
EMAIL_RECRUITMENT_USER='recruitment.kpec@gmail.com'
EMAIL_HOST='smtp.gmail.com'
EMAIL_HOST_USER='noreply.kpec@gmail.com'
EMAIL_HOST_PASSWORD=''
EMAIL_PORT='587'
EMAIL_USE_TLS = True
GOOGLE_RECAPTCHA_SECRET_KEY=''
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True
SECURE_HSTS_SECONDS = 31536000 # 1 year
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.MysqL','NAME': 'geetatare$KPECprojectDb','USER': 'geetatare','PASSWORD': '','HOST': 'geetatare.MysqL.pythonanywhere-services.com',"OPTION" : {
'init_command': 'SET default_storage_engine=INNODB'
},} }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)