django手写迁移改变auth [英] django handwritten migrations altering auth
问题描述
db.alter_column('auth_group',' name',models.CharField(max_length = 120,null = False,blank = False))
,在django 1.8中,我没有看到这样做,因为django将sql中的应用程序名称放在源代码中。我不想编辑django源代码,所以我没办法改变。我目前的attemp在这里:
class Migration(migrations.Migration):
dependencies = [
('auth','0006_require_contenttypes_0002'),
]
operations = [
migrations.AlterField('auth_group','name',field = models.CharField (max_length = 120,null = False,blank = False)),
]
请帮帮我。我不想编辑django源代码,我只想做migrations.RunSQL作为最后的手段。
谢谢@Ernest十。
在我的情况下,我保持依赖:
依赖关系= [
#指定其他依赖关系,如果需要。
('auth','0004_alter_user_username_opts')
]
确保运行python manage.py migrate得到这个反映给你的数据库。
I am using django 1.8.1 and trying to extend the length of auth_user name field from one of my apps. Before, with south, I could just target the app with an underscore like so:
db.alter_column('auth_group', 'name', models.CharField(max_length=120, null=False, blank=False))
However, in django 1.8, I don't see a way to do this as django putts the app name in the sql withing the source code. I don't want to edit django source code so I have no way of changing that. my current attemp is here:
class Migration(migrations.Migration):
dependencies = [
('auth', '0006_require_contenttypes_0002'),
]
operations = [
migrations.AlterField('auth_group', 'name', field=models.CharField(max_length=120, null=False, blank=False)),
]
Please help. I don't want to edit django source code and I only want to do migrations.RunSQL as a last resort.
Thanks @Ernest Ten.
In my case, I kept the dependency on:
dependencies = [
# Specify other dependencies, if required.
('auth', '0004_alter_user_username_opts')
]
Make sure you run "python manage.py migrate" to get this reflected to you db.
这篇关于django手写迁移改变auth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!