我有一个在本地开发了一段时间的Django项目。它在我的本地计算机上运行良好,并且我使用的是customuser设置,因此我的登录身份验证仅需要电子邮件/密码,而默认的Django用户表则需要电子邮件/用户名/密码。
我刚刚将项目托管在Heroku上,并且可以看到网页UI加载良好。但是单击任何链接时出现Django错误,并在尝试运行
时认为它与问题有关heroku run python manage.py migrate
我正在尝试在heroku上运行此程序以设置数据库,但是这样做时出现错误消息:
Running python manage.py migrate on ⬢ songsweeper... up, run.1353 (Free)
Operations to perform:
Apply all migrations: account, admin, auth, contenttypes, playlist, sessions, sites
Running migrations:
Applying account.0001_initial...Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedTable: relation "users_customuser" does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 234, in handle
fake_initial=fake_initial,
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/migrations/executor.py", line 247, in apply_migration
migration_recorded = True
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 110, in __exit__
self.execute(sql)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 137, in execute
cursor.execute(sql, params)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 99, in execute
return super().execute(sql, params)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 76, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "users_customuser" does not exist
我的项目很大,但是要概述我定义customuser的位置,它会出现在以下位置:
是否有人对如何解决此迁移错误有任何建议?还是指示性的或更有用的?我网站上的“登录”链接导致另一个错误,提示“关系“ django_site”不存在”,但我认为这与失败的customuser错误有关。
我当前正在使用默认的sqlite3 db。
答案 0 :(得分:0)
我之前遇到过和你类似的问题。 在我看来,我认为这是因为用户应用程序中的迁移文件。 因此,您必须迁移用户模型。
List<CustomerGroup> listC = listA.Except(listB, new CompareCustomerGroup()).ToList();
我用上面的方法解决了这个问题。