I am lost with what is probably a very simple issue configuring a django / mysql project. I have a working project on a computer A, which I just want to be able to use with a computer B. On computer A, I have an Eclipse project, using Pydev and Django, a local virtual environnement, and a local database running with Mysql.
What I have done:
- I exported the virtual environnement (including django) and created the same one on computer B;
- I used Gitlab in order to get all the files with the code ;
- I installed Mysql, and created a database with the same name, and a user with the same informations (id / pwd).
The migrations went well, the tables are created like I expected. However, I cannot find a way to run the server. When I try, I get multiple errors saying one (and only one) of the Apps is not loaded yet, then another error, which seems to be related to the database. Here are some of the messages:
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 : here is the code for the User model:
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")
Edit 2 : actually, it seems that most of the errors are related to the imports of the User django class, for example the errors related with forms.py is in line 2, which is this one:
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, UsernameField
I precise that I have the following line in my settings.py, since I use a personnalized User model, however I tried to delete this line and the issue persists:
AUTH_USER_MODEL = 'members.User'
I really don't understand what is happening here, so I would be gratefull if anyone can help, many thanks!