<i id='LrXnC'><tr id='LrXnC'><dt id='LrXnC'><q id='LrXnC'><span id='LrXnC'><b id='LrXnC'><form id='LrXnC'><ins id='LrXnC'></ins><ul id='LrXnC'></ul><sub id='LrXnC'></sub></form><legend id='LrXnC'></legend><bdo id='LrXnC'><pre id='LrXnC'><center id='LrXnC'></center></pre></bdo></b><th id='LrXnC'></th></span></q></dt></tr></i><div id='LrXnC'><tfoot id='LrXnC'></tfoot><dl id='LrXnC'><fieldset id='LrXnC'></fieldset></dl></div>
      • <bdo id='LrXnC'></bdo><ul id='LrXnC'></ul>
    1. <legend id='LrXnC'><style id='LrXnC'><dir id='LrXnC'><q id='LrXnC'></q></dir></style></legend>

      <small id='LrXnC'></small><noframes id='LrXnC'>

      <tfoot id='LrXnC'></tfoot>

      1. Django 1.8 测试问题:ProgrammingError: 关系“auth_user"不存在

        Django 1.8 test issue: ProgrammingError: relation quot;auth_userquot; does not exist(Django 1.8 测试问题:ProgrammingError: 关系“auth_user不存在)

        <small id='5mZxI'></small><noframes id='5mZxI'>

          1. <i id='5mZxI'><tr id='5mZxI'><dt id='5mZxI'><q id='5mZxI'><span id='5mZxI'><b id='5mZxI'><form id='5mZxI'><ins id='5mZxI'></ins><ul id='5mZxI'></ul><sub id='5mZxI'></sub></form><legend id='5mZxI'></legend><bdo id='5mZxI'><pre id='5mZxI'><center id='5mZxI'></center></pre></bdo></b><th id='5mZxI'></th></span></q></dt></tr></i><div id='5mZxI'><tfoot id='5mZxI'></tfoot><dl id='5mZxI'><fieldset id='5mZxI'></fieldset></dl></div>

                <bdo id='5mZxI'></bdo><ul id='5mZxI'></ul>
              • <legend id='5mZxI'><style id='5mZxI'><dir id='5mZxI'><q id='5mZxI'></q></dir></style></legend>
                • <tfoot id='5mZxI'></tfoot>
                    <tbody id='5mZxI'></tbody>
                  本文介绍了Django 1.8 测试问题:ProgrammingError: 关系“auth_user"不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我最近将 Django 升级到 1.8 并设置了一个新的开发数据库以重新开始.迁移和依赖关系进展顺利,避免了您遇到的常见错误并最终解决了问题.该应用程序现在在本地运行良好.

                  I recently upgraded Django to 1.8 and set up a new development database for a fresh start. Migrations and dependencies went well, safe the usual errors you get and you end up solving. The app is working locally now just fine.

                  但是,我在尝试运行测试时遇到错误:

                  However, I am getting an error when trying to run tests:

                  python manage.py test
                  

                  这是我得到的错误:

                  django.db.utils.ProgrammingError: relation "auth_user" does not exist
                  

                  不用说,django的auth模块确实是在app中安装和迁移的,所以不清楚是怎么回事.

                  Needless to say, Django's auth module is indeed installed and migrated in the app, so I am not sure what is going on.

                  这是完整的堆栈跟踪,以防您需要查看它,但它并没有说任何对我找出这个错误原因有帮助的东西:

                  Here is the full stacktrace in case you need to peek at it, but it does't say anything even remotely helpful to me to figure out the cause of this error:

                  Traceback (most recent call last):
                    File "C:/Users/dabadaba/PycharmProjects/dogpatchsports_com/mysite/manage_sched_dev.py", line 10, in <module>
                      execute_from_command_line(sys.argv)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagement\__init__.py", line 354, in execute_from_command_line
                      utility.execute()
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagement\__init__.py", line 346, in execute
                      self.fetch_command(subcommand).run_from_argv(self.argv)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementcommands	est.py", line 30, in run_from_argv
                      super(Command, self).run_from_argv(argv)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementase.py", line 394, in run_from_argv
                      self.execute(*args, **cmd_options)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementcommands	est.py", line 74, in execute
                      super(Command, self).execute(*args, **options)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementase.py", line 445, in execute
                      output = self.handle(*args, **options)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementcommands	est.py", line 90, in handle
                      failures = test_runner.run_tests(test_labels)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjango	est
                  unner.py", line 210, in run_tests
                      old_config = self.setup_databases()
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjango	est
                  unner.py", line 166, in setup_databases
                      **kwargs
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjango	est
                  unner.py", line 370, in setup_databases
                      serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangodbackendsasecreation.py", line 368, in create_test_db
                      test_flush=not keepdb,
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagement\__init__.py", line 120, in call_command
                      return command.execute(*args, **defaults)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementase.py", line 445, in execute
                      output = self.handle(*args, **options)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementcommandsmigrate.py", line 179, in handle
                      created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangocoremanagementcommandsmigrate.py", line 318, in sync_apps
                      cursor.execute(statement)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangodbackendsutils.py", line 64, in execute
                      return self.cursor.execute(sql, params)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangodbutils.py", line 98, in __exit__
                      six.reraise(dj_exc_type, dj_exc_value, traceback)
                    File "C:UsersdabadabaEnvsdjango18libsite-packagesdjangodbackendsutils.py", line 62, in execute
                      return self.cursor.execute(sql)
                  django.db.utils.ProgrammingError: relation "auth_user" does not exist
                  

                  我可以在 this answer 之后找到一种解决方法,它会阻止测试任务运行 migrate,根据我一直在阅读的内容,这应该是错误发生的地方.很奇怪,因为当我运行 migrate 时一切都很好.

                  I can figure out a workaround following this answer which prevents the test task from running migrate, which according to what I have been reading should be the point where the error happens. Odd enough, since when I run migrate everything is fine.

                  但是,我不希望采用厚颜无耻的解决方法,而是坚持按照设计的方式做事.此外,此错误可能暗示其他问题实际上是错误的,应该修复.

                  However, I would prefer not to resort to a cheeky workaround and stick to doing things as they are designed. Additionally, this error might be a hint that something else is actually wrong and ought to be fixed.

                  一些解决方案建议运行:

                  Some solutions suggest running:

                  python manage.py migrate auth
                  python manage.py migrate
                  

                  但这无济于事,因为我的项目中没有待处理的迁移.

                  But that does nothing since there are no pending migrations in my project.

                  我该如何解决这个神秘的问题?

                  How can I solve this mysterious issue?

                  推荐答案

                  如果您有任何具有 auth.User 外键的应用程序,请确保这些应用程序的初始迁移具有依赖 auth 应用:

                  If you have any apps which have foreign keys to auth.User, then make sure that the initial migrations for those apps have a dependency on the auth app:

                  class Migration(migrations.Migration):
                  
                      dependencies = [('auth', '__first__')]
                  

                  这篇关于Django 1.8 测试问题:ProgrammingError: 关系“auth_user"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Running .jl file from R or Python(从 R 或 Python 运行 .jl 文件)
                  Running Julia .jl file in python(在 python 中运行 Julia .jl 文件)
                  Using PIP in a Azure WebApp(在 Azure WebApp 中使用 PIP)
                  How to run python3.7 based flask web api on azure(如何在 azure 上运行基于 python3.7 的烧瓶 web api)
                  Azure Python Web App Internal Server Error(Azure Python Web 应用程序内部服务器错误)
                  Run python dlib library on azure app service(在 azure app 服务上运行 python dlib 库)
                    • <bdo id='Lw3DZ'></bdo><ul id='Lw3DZ'></ul>
                          <tbody id='Lw3DZ'></tbody>

                        <small id='Lw3DZ'></small><noframes id='Lw3DZ'>

                          <legend id='Lw3DZ'><style id='Lw3DZ'><dir id='Lw3DZ'><q id='Lw3DZ'></q></dir></style></legend><tfoot id='Lw3DZ'></tfoot>
                        1. <i id='Lw3DZ'><tr id='Lw3DZ'><dt id='Lw3DZ'><q id='Lw3DZ'><span id='Lw3DZ'><b id='Lw3DZ'><form id='Lw3DZ'><ins id='Lw3DZ'></ins><ul id='Lw3DZ'></ul><sub id='Lw3DZ'></sub></form><legend id='Lw3DZ'></legend><bdo id='Lw3DZ'><pre id='Lw3DZ'><center id='Lw3DZ'></center></pre></bdo></b><th id='Lw3DZ'></th></span></q></dt></tr></i><div id='Lw3DZ'><tfoot id='Lw3DZ'></tfoot><dl id='Lw3DZ'><fieldset id='Lw3DZ'></fieldset></dl></div>