django 在另一台计算机上导出后无法运行服务器(迁移工作)

qv7cva1a  于 2023-08-08  发布在  Go
关注(0)|答案(1)|浏览(150)

我迷失了一个可能是一个非常简单的问题,配置一个django / mysql项目。我在计算机A上有一个正在工作的项目,我只是想能够与计算机B一起使用。在计算机A上,我有一个Eclipse项目,使用Pydev和Django,一个本地虚拟环境,以及一个运行Mysql的本地数据库。
我所做的:

  • 我导出了虚拟环境(包括django)并在计算机B上创建了相同的环境;
  • 我使用Gitlab来获取所有包含代码的文件;
  • 我安装了Mysql,并创建了一个同名的数据库,以及一个具有相同信息的用户(id / pwd)。

迁移进行得很顺利,表的创建符合我的预期。但是,我找不到运行服务器的方法。当我尝试时,我得到多个错误,说一个(也只有一个)应用程序尚未加载,然后是另一个错误,这似乎与数据库有关。以下是一些信息:

Traceback (most recent call last):
  File "/home/francois/snap/eclipse/67/amd64/plugins/org.python.pydev.core_10.2.1.202307021217/pysrc/_pydev_runfiles/pydev_runfiles.py", line 460, in __get_module_from_str
    mod = __import__(modname)
  File "/home/francois/eclipse-workspace/iou/members/forms.py", line 2, in <module>
    from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, UsernameField
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/contrib/auth/forms.py", line 10, in <module>
    from django.contrib.auth.models import User
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
    class AbstractBaseUser(models.Model):
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/db/models/base.py", line 108, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/apps/registry.py", line 253, in get_containing_app_config
    self.check_apps_ready()
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/apps/registry.py", line 136, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
ERROR: Module: members.forms could not be imported (file: /home/francois/eclipse-workspace/iou/members/forms.py).
Traceback (most recent call last):
  File "/home/francois/snap/eclipse/67/amd64/plugins/org.python.pydev.core_10.2.1.202307021217/pysrc/_pydev_runfiles/pydev_runfiles.py", line 460, in __get_module_from_str
    mod = __import__(modname)
  File "/home/francois/eclipse-workspace/iou/members/migrations/0001_initial.py", line 3, in <module>
    import django.contrib.auth.models
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
    class AbstractBaseUser(models.Model):
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/db/models/base.py", line 108, in __new__
    app_config = apps.get_containing_app_config(module)
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/apps/registry.py", line 253, in get_containing_app_config
    self.check_apps_ready()
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/apps/registry.py", line 136, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
ERROR: Module: members.migrations.0001_initial could not be imported (file: /home/francois/eclipse-workspace/iou/members/migrations/0001_initial.py).
done.
Traceback (most recent call last):
  File "/home/francois/snap/eclipse/67/amd64/plugins/org.python.pydev.core_10.2.1.202307021217/pysrc/runfiles.py", line 268, in <module>
    main()
  File "/home/francois/snap/eclipse/67/amd64/plugins/org.python.pydev.core_10.2.1.202307021217/pysrc/runfiles.py", line 95, in main
    return pydev_runfiles.main(configuration)  # Note: still doesn't return a proper value.
  File "/home/francois/snap/eclipse/67/amd64/plugins/org.python.pydev.core_10.2.1.202307021217/pysrc/_pydev_runfiles/pydev_runfiles.py", line 857, in main
    PydevTestRunner(configuration).run_tests()
  File "/home/francois/snap/eclipse/67/amd64/plugins/org.python.pydev.core_10.2.1.202307021217/pysrc/_pydev_runfiles/pydev_runfiles.py", line 780, in run_tests
    get_django_test_suite_runner()(run_tests).run_tests([])
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/test/runner.py", line 723, in run_tests
    databases = self.get_databases(suite)
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/test/runner.py", line 702, in get_databases
    databases = self._get_databases(suite)
  File "/home/francois/anaconda3/envs/iou_env/lib/python3.10/site-packages/django/test/runner.py", line 690, in _get_databases
    for test in suite:
TypeError: 'NoneType' object is not iterable

字符串

edit:User模型代码如下:

from django.db import models
from django.contrib.auth.models import AbstractUser

class Group(models.Model):
    name = models.CharField(max_length=100)
    def __str__(self):
        return self.name   
    
class User(AbstractUser):
    groups = models.ManyToManyField(Group)
    current_group = models.ForeignKey(Group, on_delete=models.SET_NULL,blank = True , null = True, related_name="current_group")

编辑2:实际上,似乎大多数错误都与User django类的导入有关,例如与www.example.com相关的错误forms.py在第2行,这是一个:

from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, UsernameField


我确切地说,我在我的settings.py中有以下一行,因为我使用个性化的用户模型,但是我试图删除这一行,问题仍然存在:

AUTH_USER_MODEL = 'members.User'


我真的不明白这里发生了什么,所以我会很感激,如果有人能帮助,非常感谢!

5f0d552i

5f0d552i1#

所以,我不明白为什么,但问题来自Eclipse的名称- Pydev项目。似乎我不能有一个以小写字符开头的项目名称(这在另一台计算机上工作得很好,思想...)。我只是用大写字母在开头重命名了项目,它工作。
我希望它能帮助到其他人,非常感谢那些试图帮助的人!

相关问题