django.db.utils.ProgrammingError:关系“ accounts_myuser”不存在

时间:2018-12-24 21:02:02

标签: django postgresql

Ubuntu 16.04 LTS

我正在处理django项目,并且我使用的是postgresql而不是sqlite3。 问题是,当我尝试自定义“ https://docs.djangoproject.com/ko/2.1/topics/auth/customizing/”所示的用户模型时,在迁移过程中会发生错误。 在与该站点一样编辑代码之后,我添加了

from django.contrib.auth import get_user_model  
User = get_user_model()

无处不在

from django.contrib.auth.models import User

被写。 然后,在终点站,我跑了 python manage.py makemigrations 而且,我试图跑步

python manage.py migrate

但是,它不会迁移,显示此错误:

  

django.db.utils.ProgrammingError:关系“ accounts_myuser”不存在

我该如何解决?

谢谢。

--------------下面是终端上显示的内容-------------------

  

python manage.py迁移管理员   /home/seokchan/server/mdocker/lib/python3.5/site-packages/psycopg2/init.py:144:   用户警告:psycopg2滚轮包将从发行版中重命名   2.8;为了保持二进制安装,请改用“ pip install psycopg2-binary”。有关详细信息,请参见:   http://initd.org/psycopg/docs/install.html#binary-install-from-pypi。   “”“)系统检查发现了一些问题:

     

警告:?:( URL.W002)您的网址格式“ / auth”具有路由   以“ /”开头。删除此斜杠,因为它是不必要的。如果这   模式是在include()中定位的,请确保include()模式具有   尾随“ /”。要执行的操作:应用所有迁移:管理员   运行迁移:正在应用   admin.0006_auto_20181225_0549 ...回溯(最近一次拨打电话):
  文件   “ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/utils.py”,   _execute中的第85行       返回self.cursor.execute(sql,params)psycopg2.ProgrammingError:关系“ accounts_myuser”不存在

     

上述异常是以下异常的直接原因:

     

回溯(最近一次通话最近):文件“ manage.py”,第22行,在          execute_from_command_line(sys.argv)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/core/management/init.py”,   第381行,在execute_from_command_line中       utility.execute()文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/core/management/init.py”,   行375,在执行       self.fetch_command(subcommand).run_from_argv(self.argv)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/core/management/base.py”,   第316行,位于run_from_argv中       self.execute(* args,** cmd_options)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/core/management/base.py”,   第353行,在执行中       输出= self.handle(* args,** options)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/core/management/base.py”,   第83行,缠绕       res = handle_func(* args,** kwargs)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/core/management/commands/migrate.py”,   第203行,在句柄中       fake_initial = fake_initial,文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/migrations/executor.py”,   第117行,正在迁移       状态= self._migrate_all_forwards(状态,计划,完整计划,fake = fake,fake_initial = fake_initial)文件   “ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/migrations/executor.py”,   _migrate_all_forwards中的第147行       状态= self.apply_migration(状态,迁移,fake = fake,fake_initial = fake_initial)文件   “ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/migrations/executor.py”,   第244行,位于apply_migration中       状态= migration.apply(状态,schema_editor)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/migrations/migration.py”,   第124行,适用       operation.database_forwards(self.app_label,schema_editor,old_state,project_state)文件   “ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/migrations/operations/fields.py”,   第216行,在database_forwards中       schema_editor.alter_field(from_model,from_field,to_field)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/base/schema.py”,   第523行,在alter_field中       old_db_params,new_db_params(严格))文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/postgresql/schema.py”,   _alter_field中的第122行       new_db_params,严格,文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/base/schema.py”,   _alter_field中的第744行       self.execute(self._create_fk_sql(model,new_field,“ fk %(to_table)s _%(to_column)s”))文件   “ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/base/schema.py”,   第133行,在执行中       cursor.execute(sql,params)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/utils.py”,   第100行,在执行中       返回super()。execute(sql,params)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/utils.py”,   第68行,执行       返回self._execute_with_wrappers(sql,params,many = False,executor = self._execute)文件   “ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/utils.py”,   第77行,在_execute_with_wrappers中       返回执行程序(sql,params,许多,上下文)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/utils.py”,   _execute中的第85行       返回self.cursor.execute(sql,params)文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/utils.py”,   第89行,退出       从exc_value文件“ /home/seokchan/server/mdocker/lib/python3.5/site-packages/django/db/backends/utils.py”中提高dj_exc_value.with_traceback(traceback),   _execute中的第85行       返回self.cursor.execute(sql,params)django.db.utils.ProgrammingError:关系“ accounts_myuser”没有   存在

0 个答案:

没有答案