我刚刚安装了django-registration-redux
,将'registration'
添加到了INSTALLED_APPS
和urls
,但是在迁移时,我收到了下一个错误:
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
存在。
答案 0 :(得分:0)
你说你添加了login.customuser
。该名称与您在其他地方提到的login_customuser
不同。试试看它是否有效。
除此之外,我建议您一个接一个地使用makemigrations
和migrate
以获得更好的结果。