我是neewbie在这里和编程,所以请有一些怜悯:D我正在做我的第一个Django项目与马克西米利安课程。我做了Django博客。我走过了一些错误时部署,但现在我遇到了这个错误后部署,并试图访问我的网站上的AWS:
Django - deterministic=True requires SQLite 3.8.3 or higher upon running python manage.py runserver
但在辩论页面上还有更多的东西:在模板/var/应用程序/当前/博客/模板/博客/index. html中,错误位于l
在第25行中以粗体显示:
{% url 'single_post' slug=all_posts.0.slug %}
all_post是一个queryset类型的上下文变量。这一行有什么问题吗?在本地机器上一切正常
所以我找到了这个解决方案:
Django - deterministic=True requires SQLite 3.8.3 or higher upon running python manage.py runserver
所以我是这样理解的:
1.在ubuntu终端i中键入:sudo apt install python3.10-venv
安装环境
1.然后在Visual Studio i的Django项目中输入python3 -m venv django_my_site
来创建虚拟环境
1.现在,我单击“+”打开此环境,然后键入pip3 install pysqlite3
和pip3 install pysqlite3-binary
1.然后输入python3 -m pip freeze > requirements.txt
然后我得到requirements.txt文件,看起来像这样:
asgiref==3.6.0
Django==4.1.4
Pillow==9.3.0
pysqlite3==0.5.0
pysqlite3-binary==0.5.0
sqlparse==0.4.3
1.我还在www.example.com中添加了3行settings.py:
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
1.之后,我再次包所有必要的文件夹和项目的文件.
1.在AWS的应用程序版本中,我再次上传zip并部署。
1.我重新启动了示例,服务器状态正常,但仍然出现了sqlite错误。
日志文件的一些有趣部分:
2023/01/02 15:10:03 [warn] 344#344: *157 using uninitialized "month" variable while logging request, client: 192.155.90.118, server: , request: "\00\85\00\00\81\A0cw\9BP\A3\F8U[Z0\EB\A0=\8Ba\CC!\F8ؼ\DD\FB\C9\C0"
2023/01/02 15:10:03 [warn] 344#344: *157 using uninitialized "day" variable while logging request, client: 192.155.90.118, server: , request: "\00\85\00\00\81\A0cw\9BP\A3\F8U[Z0\EB\A0=\8Ba\CC!\F8ؼ\DD\FB\C9\C0"
2023/01/02 15:10:03 [warn] 344#344: *157 using uninitialized "hour" variable while logging request, client: 192.155.90.118, server: , request: "\00\85\00\00\81\A0cw\9BP\A3\F8U[Z0\EB\A0=\8Ba\CC!\F8ؼ\DD\FB\C9\C0"
Jan 2 18:11:17 ip-172-31-87-96 web: create_deterministic_function("django_date_extract", 2, _sqlite_datetime_extract)
Jan 2 18:11:17 ip-172-31-87-96 web: django.db.utils.NotSupportedError: deterministic=True requires SQLite 3.8.3 or higher
Jan 2 18:14:34 ip-172-31-87-96 web: Invalid HTTP_HOST header: '54.147.47.55'. You may need to add '54.147.47.55' to ALLOWED_HOSTS.
所有日志文件:
https://files.fm/f/27h4mjf9t
链接到我的存储库:
https://github.com/Stanotech/my_site.git
www.example.com中的一些设置settings.py:
from pathlib import Path
from os import getenv
ALLOWED_HOSTS = [
getenv("APP_HOST")
]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog'
]
ROOT_URLCONF = 'my_site.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 = 'my_site.wsgi.application'
__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_ROOT = BASE_DIR / "staticfiles"
STATIC_URL = '/static/'
STATICFILES_DIRS = [
BASE_DIR / "static"
]
MEDIA_ROOT = BASE_DIR / "uploads"
MEDIA_URL = "/user-media/"
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
SESSIONS_COOKIE_AGE = 9999
1条答案
按热度按时间nx7onnlm1#
你试过设置环境来使用python 3.7吗