弹性beantalk无法创建超级用户,语法无效
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了弹性beantalk无法创建超级用户,语法无效相关的知识,希望对你有一定的参考价值。
我只是试图创建一个超级用户,以便可以登录到我网站的admin部分。到目前为止,其他所有工作。这是我的活动错误日志的相关部分:
[2019-12-22T05:02:06.721Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Test for Command 02_createsuperuser] : Starting activity...
[2019-12-22T05:02:06.725Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Test for Command 02_createsuperuser] : Completed activity. Result:
Completed successfully.
[2019-12-22T05:02:06.726Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Command 02_createsuperuser] : Starting activity...
[2019-12-22T05:02:07.074Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Command 02_createsuperuser] : Activity execution failed, because: Traceback (most recent call last):
File "/opt/python/current/app/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/commands/shell.py", line 92, in handle
exec(sys.stdin.read())
File "<string>", line 1
from users.models import UserProfile; UserProfile.objects.create_superuser(xxxxxxx@gmail.com', 'passxxxword')
^
SyntaxError: invalid syntax
(ElasticBeanstalk::ExternalInvocationError)[2019-12-22T05:02:06.721Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Test for Command 02_createsuperuser] : Starting activity...
[2019-12-22T05:02:06.725Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Test for Command 02_createsuperuser] : Completed activity. Result:
Completed successfully.
[2019-12-22T05:02:06.726Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Command 02_createsuperuser] : Starting activity...
[2019-12-22T05:02:07.074Z] INFO [26175] - [Application update app-191222_070106@18/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ss_app/Command 02_createsuperuser] : Activity execution failed, because: Traceback (most recent call last):
File "/opt/python/current/app/manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/base.py", line 353, in execute
output = self.handle(*args, **options)
File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/management/commands/shell.py", line 92, in handle
exec(sys.stdin.read())
File "<string>", line 1
from users.models import UserProfile; UserProfile.objects.create_superuser(xxxxxxx@gmail.com', 'passxxxword')
^
SyntaxError: invalid syntax
(ElasticBeanstalk::ExternalInvocationError)
我正在尝试通过db-migrate.config文件进行部署:
container_commands:
01_migrate:
command: "django-admin.py migrate"
leader_only: true
02_createsuperuser:
command: "echo \"from users.models import UserProfile; UserProfile.objects.create_superuser(xxxxxxx@gmail.com', 'passxxxword')\" | /opt/python/run/venv/bin/python /opt/python/current/app/manage.py shell"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: studyspot.settings
答案
Elastic beanstalk终于在db-migrate.config文件中接受了我的超级用户命令:
02_createsuperuser:
command: "echo \"from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('xxxxx@gmail.com', 'xxxxxpasword')\" | python manage.py shell"
这使用的是自定义用户模型,目前尚无太多信息,因此希望对您有所帮助。我没有在此处包括managers.py文件,但是该部分应该很简单,并且我确实必须确保在forms.py文件的用户创建表单中具有保存用户功能。这花了我一周的时间来弄清楚,因此我将其发布以帮助他人。
以上是关于弹性beantalk无法创建超级用户,语法无效的主要内容,如果未能解决你的问题,请参考以下文章