我对 Django 迁移功能有疑问。我试图向我的用户模型添加新字段,它看起来像这样。
class UserProfile(models.Model):
""" Model to represent additional information about user """
user = models.OneToOneField(
User,
on_delete=models.CASCADE,
related_name='profile'
)
bio = models.TextField(
max_length=2000,
blank=True,
default=''
)
# we use URL instead of imagefield because we'll use 3rd party img hosting later on
avatar = models.URLField(default='', blank=True)
status = models.CharField(max_length=16, default='', blank=True)
name = models.CharField(max_length=32, default='')
balance = models.BigIntegerField(default='0')
def __str__(self):
return self.user.username
余额是我添加的新内容,之后我收到了类似的消息
要执行的操作:应用所有迁移:帐户、管理员、auth、authtoken、内容类型、论坛、帖子、会话、线程运行迁移:应用 accounts.0005_userprofile_balance...Traceback(最近一次调用最后):文件“manage.py”,第 15 行,在 execute_from_command_line(sys.argv) 文件“C:\Users\Rade\Desktop\rengorum-master\backend\env\lib\site-packages\django\core\management__init__.py”中,第 371 行,在 execute_from_command_line 实用程序中.execute() 文件“C:\Users\Rade\Desktop\rengorum-master\backend\env\lib\site-packages\django\core\management__init__.py”,第 365 行,在执行 self.fetch_command(子命令)中。 run_from_argv(self.argv) 文件“C:\Users\Rade\Desktop\rengorum-master\backend\env\lib\site-packages\django\core\management\base.py”,第 288 行,在 run_from_argv self.execute(*args, **cmd_options) 文件“C:\Users\Rade\Desktop\rengorum-master\backend\env\lib\site-packages\django\core\management\base.py”中,行335,在执行输出 = self.handle(*args, **options) 文件“C:\Users\Rade\Desktop\rengorum-master\backend\env\lib\site-packages\django\core\management\commands\ migrate.py”,第 200 行,在句柄 fake_initial=fake_initial,文件“C:\Users\Rade\Desktop\rengorum-master\backend\env\lib\site-packages\django\db\migrations\executor.py”中,第 117 行,迁移状态 =
收到该消息后,我尝试将默认值设置为 0.00,但它仍然是相同的消息,我删除了余额字段并仍然收到相同的消息。有任何想法吗?
呼啦一阵风
慕标5832272
相关分类