我无法使用Django创建列AWS RDS数据库[关闭]

yi0zb3m4  于 2023-08-08  发布在  Go
关注(0)|答案(1)|浏览(106)

已关闭。此问题需要更多focused。它目前不接受回答。
**希望改进此问题?**更新问题,使其仅针对editing this post的一个问题。

8天前关闭。
Improve this question
当我在models.py文件中添加代码以创建如下所示的新列时,

partnerId = models.IntegerField(null=True, blank=True, default=None) # added

字符串
并执行“python manage.py makemigrations”和“python manage.py migrate”,迁移成功完成,但'partnerId'列'仅在本地mysql数据库中创建,而不是在aws rds mysql数据库中创建。
这个问题怎么办?
如何运行ec2 srvr(python manage.py makemigrations)

ubuntu@ip-172-31-0-41:~$ python manage.py makemigrations
Command 'python' not found, did you mean:
  command 'python3' from deb python3
  command 'python' from deb python-is-python3
ubuntu@ip-172-31-0-41:~$ python3 manage.py makemigrations
python3: can't open file '/home/ubuntu/manage.py': [Errno 2] No such file or directory
ubuntu@ip-172-31-0-41:~$ ls
srv
ubuntu@ip-172-31-0-41:~$ cd srv
ubuntu@ip-172-31-0-41:~/srv$ ls
ubuntu
ubuntu@ip-172-31-0-41:~/srv$ cd ubuntu
ubuntu@ip-172-31-0-41:~/srv/ubuntu$ ls
Dockerfile       README.md      accounts  config      docker-compose.prod.yml  emotions  manage.py         schedule
Dockerfile.prod  TherapEase-BE  api       counselees  docker-compose.yml       main.py   requirements.txt
ubuntu@ip-172-31-0-41:~/srv/ubuntu$ python3 manage.py makemigrations
Traceback (most recent call last):
  File "/home/ubuntu/srv/ubuntu/manage.py", line 11, in main
    from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/srv/ubuntu/manage.py", line 22, in <module>
    main()
  File "/home/ubuntu/srv/ubuntu/manage.py", line 13, in main
    raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?

b1payxdu

b1payxdu1#

从你的错误中,看起来Django没有安装在你的AWS EC2示例上。你在评论中提到你必须激活venv。它可以在本地Django终端中工作,因为您可能已经在系统中全局安装了Django,而不是在虚拟环境中。所以在aws ec2中,你首先要创建venv,然后激活它,然后安装你的项目依赖,包括Django,然后你就可以运行你的迁移命令,它应该工作。

相关问题