简体   繁体   English

Django AWS ElasticBeanstalk Deploy- 错误确定性=True 需要 SQLite 3.8.3 或更高版本

[英]Django AWS ElasticBeanstalk Deploy- error deterministic=True requires SQLite 3.8.3 or higher

Im trying to deploy my application my EB status it returned green, so it's working我试图部署我的应用程序我的 EB 状态它返回绿色,所以它正在工作

So, i deployed my application in my local venv i did python make migrations python migrate eb deploy and eb status因此,我在本地 venv 中部署了我的应用程序,我做了python make migrations python migrate eb deployeb status

the helth returned green so its working, but when i enter the web site it returns deterministic=True requires SQLite 3.8.3 or higher helth 返回绿色,因此可以正常工作,但是当我进入 web 站点时,它返回deterministic=True requires SQLite 3.8.3 or higher

Note: Locally it works just fine注意:在本地它工作得很好

django.config: django.config:

option_settings:
    aws:elasticbeanstalk:container:python:
        WSGIPath: store.wsgi:application

commands that i ran to make my project:我为制作项目而运行的命令:

python manage.py mamemigrations
python manage.py migrate 
python manage.py createsuperuser
eb init python-3.8 Naameofmyproject
eb create Nameofmyproject

Requirments.txt:要求.txt:

asgiref==3.5.0
autopep8==1.6.0
certifi==2021.10.8
charset-normalizer==2.0.12
dj-database-url==0.5.0
Django==4.0.3
django-anymail==8.5
django-autoslug==1.9.8
django-crispy-forms==1.14.0
django-environ==0.8.1
django-model-utils==4.2.0
idna==3.3
Pillow==9.1.0
psycopg2-binary==2.9.3
pycodestyle==2.8.0
python-dateutil==1.5
requests==2.27.1
six==1.16.0
sqlparse==0.4.2
stripe==2.70.0
toml==0.10.2
tzdata==2022.1
urllib3==1.26.9

settings.py:设置.py:

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


STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'static'
STATICFILES_DIRS = [BASE_DIR / 'templates/static']

MEDIA_URL = '/media/'
MEDIA_ROOT = BASE_DIR / 'media'

CART_SESSION_ID = 'cart'
AUTH_USER_MODEL = 'account.UserBase'
LOGIN_REDIRECT_URL = '/account/dashboard'
LOGIN_URL = '/account/login/'

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Step zero: The obvious - make sure your project works, and that the database has the updated migrations.步骤零:显而易见 - 确保您的项目正常工作,并且数据库具有更新的迁移。

Then follow these steps:然后按照以下步骤操作:

  1. Log into the cloud of where you're trying to deploy your application.登录到您尝试部署应用程序的云。 Click "resources", attach a postgres database if you haven't already.单击“资源”,如果还没有,请附加一个 postgres 数据库。

  2. Click on the database resource, view the credentials.单击数据库资源,查看凭据。

You'll be provided with credentials such as Host, Database, User, Port, Password, URI.您将获得诸如主机、数据库、用户、端口、密码、URI 等凭据。

在此处输入图像描述

This is what I got from Heroku.这是我从 Heroku 得到的。 I'm hiding my credentials for security reasons.出于安全原因,我隐藏了我的凭据。

  1. Uncomment the database format for SQLite in your settings.py file and use the Oracle/postgres database format like so:在 settings.py 文件中取消注释 SQLite 的数据库格式并使用 Oracle/postgres 数据库格式,如下所示: 在此处输入图像描述

I'm copying and pasting a sample from the django manual (that you can copy and paste into the settings.py file):我正在复制并粘贴 django 手册中的示例(您可以将其复制并粘贴到 settings.py 文件中):

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': 'xe',
        'USER': 'a_user',
        'PASSWORD': 'a_password',
        'HOST': 'dbprod01ned.mycompany.com',
        'PORT': '1540',
    }
}

Set the ENGINE field to:将 ENGINE 字段设置为:

'ENGINE': 'django.db.backends.postgresql',

Source: https://docs.djangoproject.com/en/4.0/ref/databases/来源: https://docs.djangoproject.com/en/4.0/ref/databases/

Populate the fields with the correct values that have been provided by the postgres resource on the cloud.使用云上的 postgres 资源提供的正确值填充字段。

  1. Ensure you have "gunicorn" installed and create a "procfile" in the same directory level as the requirements.txt file.确保您已安装“gunicorn”并在与 requirements.txt 文件相同的目录级别中创建“procfile”。

You need one line of text in the procfile:您需要 procfile 中的一行文本:

web: gunicorn [PROJECT NAME].wsgi

Your project name will be found in wsgi.py as [PROJECT NAME].settings您的项目名称将在 wsgi.py 中作为 [PROJECT NAME].settings 找到在此处输入图像描述

IMPORTANT: After changing the database in the settings.py script, delete your old migrations (they belong to SQLite).重要提示:在 settings.py 脚本中更改数据库后,删除旧迁移(它们属于 SQLite)。 Right click the migrations folder, reveal contents, delete everything except for the __ init __.py file.右键单击迁移文件夹,显示内容,删除除 __ init __.py 文件之外的所有内容。

Then create the new migrations which will now be for the postgres database:然后创建新的迁移,现在将用于 postgres 数据库:

python manage.py makemigrations

Now deploy again.现在再次部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM