I've encountered an issue with django-modeltranslation in my Django projects, which leads to an AttributeError when I add 'modeltranslation' to my INSTALLED_APPS in settings.py. The error message is as follows:
AttributeError: 'str' object has no attribute 'mro'
This error is triggered during the Django development server startup and seems to be related to the model loading process. The traceback points to an interaction with cuser.middleware.CuserMiddleware, although cuser is not directly used or mentioned in my INSTALLED_APPS or MIDDLEWARE.
Environment:
Django Version: ^4.2.0
django-modeltranslation Version: ^0.18
Python Version: 3.10
Steps to Reproduce:
Add 'modeltranslation' to INSTALLED_APPS in settings.py.
Start the Django development server with python manage.py runserver.
The error occurs during the server startup.
What I've Checked:
My INSTALLED_APPS and MIDDLEWARE settings do not explicitly include cuser.
All packages, including Django and django-modeltranslation, are updated to their latest versions compatible with my environment.
My custom user model extends AbstractUser and is correctly referred to in AUTH_USER_MODEL.
There are no explicit dependencies on cuser in my project's codebase.
I'm unsure why django-modeltranslation's integration would affect or trigger an error related to cuser, especially since cuser is not a direct dependency in my project. I suspect there might be an indirect interaction or conflict happening when models are loaded or translated by django-modeltranslation.
Could you please provide any insights or suggestions on how to resolve this issue? Is there a known compatibility issue with Django, cuser or a specific configuration required to avoid such conflicts?
Thank you for your assistance.
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/home/niko/.local/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/niko/.local/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "/home/niko/.local/lib/python3.10/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/home/niko/.local/lib/python3.10/site-packages/django/core/management/__init__.py", line 394, in execute
autoreload.check_errors(django.setup)()
File "/home/niko/.local/lib/python3.10/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/niko/.local/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/niko/.local/lib/python3.10/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/home/niko/.local/lib/python3.10/site-packages/django/apps/config.py", line 269, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/home/niko/.local/lib/python3.10/site-packages/modeltranslation/models.py", line 31, in <module>
from cuser.middleware import CuserMiddleware
File "/home/niko/.local/lib/python3.10/site-packages/cuser/middleware.py", line 3, in <module>
from cuser.compat import User
File "/home/niko/.local/lib/python3.10/site-packages/cuser/compat.py", line 15, in <module>
User = lazy(get_user_model, AUTH_USER_MODEL)
File "/home/niko/.local/lib/python3.10/site-packages/django/utils/functional.py", line 175, in lazy
for type_ in resultclass.mro():
AttributeError: 'str' object has no attribute 'mro'
Hello,
I've encountered an issue with
django-modeltranslation
in my Django projects, which leads to anAttributeError
when I add'modeltranslation'
to myINSTALLED_APPS
insettings.py
. The error message is as follows:This error is triggered during the Django development server startup and seems to be related to the model loading process. The traceback points to an interaction with
cuser.middleware.CuserMiddleware
, althoughcuser
is not directly used or mentioned in myINSTALLED_APPS
orMIDDLEWARE
.Environment:
Steps to Reproduce:
'modeltranslation'
toINSTALLED_APPS
insettings.py
.python manage.py runserver
.What I've Checked:
INSTALLED_APPS
andMIDDLEWARE
settings do not explicitly includecuser
.django-modeltranslation
, are updated to their latest versions compatible with my environment.AbstractUser
and is correctly referred to inAUTH_USER_MODEL
.cuser
in my project's codebase.I'm unsure why
django-modeltranslation
's integration would affect or trigger an error related tocuser
, especially sincecuser
is not a direct dependency in my project. I suspect there might be an indirect interaction or conflict happening when models are loaded or translated bydjango-modeltranslation
.Could you please provide any insights or suggestions on how to resolve this issue? Is there a known compatibility issue with Django, cuser or a specific configuration required to avoid such conflicts?
Thank you for your assistance.