【问题标题】:Custom user and django-registration-redux error when migrate迁移时自定义用户和 django-registration-redux 错误
【发布时间】:2015-05-05 14:04:56
【问题描述】:

我刚刚安装了django-registration-redux,将'registration' 添加到INSTALLED_APPSurls,但是在迁移时,我收到下一个错误:

Synchronizing apps without migrations:
  Creating tables...
    Creating table core_brand
    Creating table core_product
    Creating table core_package
    Creating table core_consignment
    Creating table core_slider
    Creating table core_slideritems
    Creating table order_cart
    Creating table order_order
    Creating table order_orderproduct
    Creating table registration_registrationprofile
    Running deferred SQL...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 179, in handle
    created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "C:\Python27\lib\site-packages\django\core\management\commands\migrate.py", line 317, in sync_apps
    cursor.execute(statement)
  File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Python27\lib\site-packages\django\db\backends\utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "login_customuser" does not exist

问题是我使用CustomUser 模型。我用下一个方法来做:class

CustomUser(AbstractUser):
    mobile = models.CharField(max_length=20)
    address = models.CharField(max_length=100)

settings.py 中添加了AUTH_USER_MODEL = 'login.CustomUser' 为什么会出现这个错误?因为,在这个错误之后,我查看了数据库表并且login_customuser 存在。

【问题讨论】:

    标签: django django-models django-registration


    【解决方案1】:

    你说你添加了login.customuser。该名称与您在其他地方提到的login_customuser 不同。试试看它是否有效。 除此之外,我建议你一个接一个地使用makemigrationsmigrate 以获得更好的结果。

    【讨论】:

      猜你喜欢
      • 2016-07-06
      • 2016-06-14
      • 1970-01-01
      • 2016-04-21
      • 1970-01-01
      • 2013-09-09
      • 1970-01-01
      • 2013-02-24
      • 1970-01-01
      相关资源
      最近更新 更多