一些與Django的makemigrations錯去,像下面的代碼:Django的makemigrations不起作用
class User(AbstractBaseUser, PermissionsMixin):
nickname = models.CharField(max_length=30, blank=True, verbose_name=u'')
is_staff = models.BooleanField(default=False, verbose_name=u'')
is_active = models.BooleanField(default=True, verbose_name=u'')
objects = UserManager()
當我運行python manage.py makemigrations
,現場is_staff
不遷移文件顯示出來。我不知道爲什麼這個領域消失。但如果我將名稱更改爲is_aa
,則表明它是正確的。
遷移文件是:
class Migration(migrations.Migration):
initial = True
dependencies = [
('auth', '0008_alter_user_username_max_length'),
]
operations = [
migrations.CreateModel(
name='User',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('password', models.CharField(max_length=128, verbose_name='password')),
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
('nickname', models.CharField(blank=True, max_length=30, verbose_name='\u6635\u79f0')),
('is_active', models.BooleanField(default=True, verbose_name='\u662f\u5426\u6709\u6548')),
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')),
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')),
],
options={
'db_table': 'user',
},
managers=[
('objects', apps.api.user.models.UserManager()),
],
),
只是刪除'property' is_staff – zimmer
是否[這](https://docs.djangoproject.com/en/1.11/topics/auth/customizing /#更改爲自定義用戶模型 - 項目中)適用於您的情況? – Melvyn
是的,財產和領域是重複的,只是刪除財產 – zimmer