Error accessing Admin portal (TypeError: the 'package' argument is required to perform a relative import for '..')

Every time I try to log into the Django admin portal, I get this error: TypeError: the 'package' argument is required to perform a relative import for '..'

This is my settings.py:

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-5o#%8slj&(#g)kdcy4)(&c6v^)febj7&i$19!-#l@7um-i(e8@'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'user',
    'oauth2_provider',
    'rest_framework',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'oauth2_provider.middleware.OAuth2TokenMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'config.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'config.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

# User Model
AUTH_USER_MODEL = "user.User"

# Login URLs
LOGIN_URL='/admin/'

# OAuth2
OAUTH2_PROVIDER = {
    'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'groups': 'Access to your groups'}
}

AUTHENTICATION_BACKENDS = [
    'oauth2_provider.backends.OAuth2Backend',
    # Uncomment following if you want to access the admin
    'django.contrib.auth.backends.ModelBackend',
    '...',
]

# REST
# REST_FRAMEWORK = {
#     'DEFAULT_AUTHENTICATION_CLASSES': (
#         'oauth2_provider.contrib.rest_framework.OAuth2Authentication',
#     ),

#     'DEFAULT_PERMISSION_CLASSES': (
#         'rest_framework.permissions.IsAuthenticated',
#     ),
# }

# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_URL = 'static/'

# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

Here is my requirements.txt:

Django==4.2.5
djangorestframework==3.14.0
Pillow==10.0.1
jsonmodels==2.6.0
django-oauth-toolkit==2.3.0

This is the traceback:

Internal Server Error: /admin/login/
Traceback (most recent call last):
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    **self.each_context(request),
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    "available_apps": self.get_app_list(request),
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    app_dict = self._build_app_dict(request, app_label)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    has_module_perms = model_admin.has_module_permission(request)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    return request.user.has_module_perms(self.opts.app_label)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    return _user_has_module_perms(self, module)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\sit
    for backend in auth.get_backends():
tils\module_loading.py", line 31, in import_string
    return cached_import(module_path, class_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\site-packages\django\utils\module_loading.py", line 16, in cached_import
    module = import_module(module_path)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\alex.MICHARSKI\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 121, in import_module
    raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for 
'..'
[26/Sep/2023 08:13:11] "GET /admin/login/?next=/admin/ HTTP/1.1" 500 129901

Can you share your project folders and file structure

I was able to reproduce this error by adding “…” to AUTHENTICATION_BACKENDS in one of my projects.
I am talking about this ellipsis:

AUTHENTICATION_BACKENDS = [
    '...',
]

And my guess is that removing this line from AUTHENTICATION_BACKENDS could fix the issue.