Home > front end >  No module named 'account'
No module named 'account'

Time:06-01

ModuleNotFoundError at /admin/login/ No module named 'account'

I have an app called users not account. The error is only when I submit login form or go to http://localhost:8000/admin/login/

You can also view full project on https://github.com/cell20/twitter

Full Traceback:


Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/

Django Version: 4.0.4
Python Version: 3.9.7
Installed Applications:
['users.apps.UsersConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django_extensions',
 'faker']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback (most recent call last):
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\utils\decorators.py", line 46, in _wrapper
    return bound_method(*args, **kwargs)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\views\decorators\cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\admin\sites.py", line 422, in login
    **self.each_context(request),
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\admin\sites.py", line 337, in each_context
    "available_apps": self.get_app_list(request),
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\admin\sites.py", line 537, in get_app_list
    app_dict = self._build_app_dict(request)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\admin\sites.py", line 477, in _build_app_dict
    has_module_perms = model_admin.has_module_permission(request)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\admin\options.py", line 606, in has_module_permission
    return request.user.has_module_perms(self.opts.app_label)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\auth\models.py", line 483, in has_module_perms
    return _user_has_module_perms(self, module)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\auth\models.py", line 230, in _user_has_module_perms
    for backend in auth.get_backends():
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\auth\__init__.py", line 38, in get_backends
    return _get_backends(return_tuples=False)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\auth\__init__.py", line 27, in _get_backends
    backend = load_backend(backend_path)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\contrib\auth\__init__.py", line 21, in load_backend
    return import_string(path)()
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\utils\module_loading.py", line 30, in import_string
    return cached_import(module_path, class_name)
  File "E:\Dev\realpython\django\projects\django-social\venv\lib\site-packages\django\utils\module_loading.py", line 15, in cached_import
    import_module(module_path)
  File "C:\Users\Suhail\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
    <source code not available>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
    <source code not available>
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
    <source code not available>
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
    <source code not available>
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
    <source code not available>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
    <source code not available>
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
    <source code not available>

Exception Type: ModuleNotFoundError at /admin/login/
Exception Value: No module named 'account'


CodePudding user response:

In settings.py, the custom auth backend in AUTHENTICATION_BACKENDS is set to 'account.authentication.EmailAuthBackend' instead of 'users.authentication.EmailAuthBackend'. Make sure to clear out your session data before retrying.

  • Related