gpt4 book ai didi

python - Django 迁移真的很糟糕

转载 作者:行者123 更新时间:2023-12-01 07:11:50 24 4
gpt4 key购买 nike

当我运行 makemigrations 然后迁移时,我得到以下输出:

(roundwellenv) ruben@ruben-H81M-D2V:~/roundwell$ ./dev_migrations.sh 
No changes detected in apps 'contenttypes', 'parents', 'admin', 'tips', 'tutors', 'login', 'auth', 'quiz', 'sessions'
Operations to perform:
Apply all migrations: admin, auth, contenttypes, login, parents, quiz, sessions, tips, tutors
Running migrations:
Applying contenttypes.0001_initial... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0001_initial... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying login.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying parents.0001_initial... OK
Applying quiz.0001_initial... OK
Applying sessions.0001_initial... OK
Applying tips.0001_initial... OK
Applying tutors.0001_initial... OK
(roundwellenv) ruben@ruben-H81M-D2V:~/roundwell$ python manage.py createsuperuser

You have 21 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, login, parents, quiz, sessions, tips, tutors.
Run 'python manage.py migrate' to apply them.

我知道确实出了问题,因为即使我删除了 pycache 内容以及迁移文件夹中的内容和一个干净的 sqlite3 数据库,它实际上也找不到任何需要应用的迁移,除非我指定了我想要创建迁移的应用程序为了。关于可能导致此问题的任何线索吗?我怀疑这可能是我的自定义登录应用程序,但是一旦迁移完成(就像它们在系统上实际运行的网站一样),数据库就可以正常工作。

最佳答案

尝试在项目文件夹中运行以下命令:

find . -path "*/migrations/*.py" -not -name "__init__.py" -delete
find . -path "*/migrations/*.pyc" -delete

然后删除您的 sqlite 数据库,然后再次尝试迁移。

Make sure you are in your project folder, or else this command will break your Django download!

关于python - Django 迁移真的很糟糕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58171117/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com