根据 Django 文档 (here):
django.contrib.sites registers a post_migrate signal handler which creates a default site named example.com with the domain example.com. This site will also be created after Django creates the test database. To set the correct name and domain for your project, you can use a data migration.
直接从 Django 管理面板更改默认值不是安全吗?为什么?
最佳答案
这是我的回答。 第一个选项是在 Django 管理站点上更改它们。 第二个选项是手动创建迁移文件并运行迁移。 让我在这里描述第二个选项。 首先,使用以下命令创建一个空迁移。
$ python manage.py makemigrations --empty --name update_site_name app_name
接下来引用这个blog编辑迁移文件。
最后,运行迁移。
谢谢。
关于django - 将默认 Django 站点名称和域从 example.com 更改为正确的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65733649/