django - Django migration duplicate operation
问题描述
I'm using Django
for the backend of my application and everything is fine except a little problem with my migrations.
I'm using a custom User model by inheriting from AbstractUser
and I have something like the following :
class User(AbstractUser):
class Meta:
verbose_name = "User"
# Fields and methods here
# ...
which results in this part of the migration in my 0001_initial.py
migration file :
options={
'verbose_name': 'User',
'verbose_name_plural': 'Users',
'abstract': False,
},
The thing is, when I run makemigrations
later on, it creates an automatic migration with this little part in it :
migrations.AlterModelOptions(
name='user',
options={'verbose_name': 'User'},
),
I do not understand why it tries to apply this modification a second time. Can someone help me ?
I could let it as it is but I try to keep my migration files as clean as possible.
Thanks in advance.
解决方案
Well ! Since I haven't been able to understand what was going on, I decided to try deleting all the migrations (I'm not yet in production so I could !) and generate them back.
It ended up with this part for my User model :
options={
'verbose_name': 'User',
},
Which is what I already had but...eh.
The good thing is that running makemigrations
after that no longer generate weird things.
推荐阅读
- c++ - openmp 嵌套循环处理性能
- kubernetes - Kubernetes Nginx Ingress 未正确重定向到路径路由服务
- node.js - node.js 中的 TEAMS 机器人:CreateConversation 方法中的“此请求的授权已被拒绝”
- excel - 如何根据每月用户数据在 Excel 中创建历史数据库
- android - 使APP android读取文件的内容 - IONIC
- node.js - 如何使用 Winston 库在 Node.js 中每天将 logrotate 日志记录到单独的文件中
- c++ - 为什么调用模板类函数时会出现 SEGFAULT?
- python - 想要通过占位符选择用于运行时训练的变量
- python-3.x - 将类及其功能从一个文件导入到另一个文件
- operating-system - Android One 是否支持 ARCore?