Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors logged #1058

Open
jonasN5 opened this issue Oct 23, 2024 · 7 comments
Open

Errors logged #1058

jonasN5 opened this issue Oct 23, 2024 · 7 comments

Comments

@jonasN5
Copy link

jonasN5 commented Oct 23, 2024

When accessing the admin page, we currently have a bunch of errors logged:

2024-10-23 16:15:20,746 [DEBUG] django.template: Exception while resolving variable 'debug' in template 'admin/index.html'.
Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 883, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/context.py", line 85, in __getitem__
    raise KeyError(key)
KeyError: 'debug'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 889, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(
                                            ^^^^^^^^
AttributeError: type object 'RequestContext' has no attribute 'debug'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 899, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'debug'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 906, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [debug] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x1085ab1a0>>, 'request': <WSGIRequest: GET '/admin/'>, 'user': <SimpleLazyObject: <User: myUser>>, 'perms': PermWrapper(<SimpleLazyObject: <User: myUser>>), 'messages': <FallbackStorage: request=<WSGIRequest: GET '/admin/'>>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}}, {}, {'site_title': 'Django site admin', 'site_header': 'Django administration', 'site_url': '/', 'has_permission': True, 'available_apps': [{'name': 'Authentication and Authorization', 'app_label': 'auth', 'app_url': '/admin/auth/', 'has_module_perms': True, 'models': [{'model': <class 'django.contrib.auth.models.Group'>, 'name': 'Groups', 'object_name': 'Group', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'view_only': False}, {'model': <class 'django.contrib.auth.models.User'>, 'name': 'Users', 'object_name': 'User', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/user/', 'add_url': '/admin/auth/user/add/', 'view_only': False}]}], 'is_popup': False, 'is_nav_sidebar_enabled': True, 'log_entries': <QuerySet []>, 'title': 'Site administration', 'subtitle': None, 'app_list': [{'name': 'Authentication and Authorization', 'app_label': 'auth', 'app_url': '/admin/auth/', 'has_module_perms': True, 'models': [{'model': <class 'django.contrib.auth.models.Group'>, 'name': 'Groups', 'object_name': 'Group', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'view_only': False}, {'model': <class 'django.contrib.auth.models.User'>, 'name': 'Users', 'object_name': 'User', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/user/', 'add_url': '/admin/auth/user/add/', 'view_only': False}]}], 'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False}, {'block': <Block Node: javascripts. Contents: [<TextNode: '\n    '>, <Variable Node: block.super>, <TextNode: '\n'>]>}, {'block': <Block Node: javascripts. Contents: [<TextNode: '\n        <script type="te'>, <django.template.defaulttags.FilterNode object at 0x108656a90>, <TextNode: '";</script>\n        <scri'>, <django.template.defaulttags.FilterNode object at 0x108529f90>, <TextNode: '";</script>\n        <scri'>, <URLNode view_name=''admin:index'' args=[] kwargs={} as=None>, <TextNode: '",\n                MODEL_'>, <IfNode>, <TextNode: ',\n                DATE_FO'>, <django.template.library.SimpleNode object at 0x10866f350>, <TextNode: '",\n                TIME_F'>, <django.template.library.SimpleNode object at 0x10866f450>, <TextNode: '",\n                DATETI'>, <django.template.library.SimpleNode object at 0x10866f550>, <TextNode: '";\n        </script>\n    '>, StaticNode(varname=None, path=<FilterExpression '"grappelli/jquery/jquery.min.js"'>), <TextNode: '" type="text/javascript">'>, StaticNode(varname=None, path=<FilterExpression '"grappelli/jquery/jquery-migrate-3.0.1.min.js"'>), <TextNode: '" type="text/javascript">'>, StaticNode(varname=None, path=<FilterExpression '"grappelli/jquery/ui/jquery-ui.min.js"'>), <TextNode: '" type="text/javascript">'>, <IfNode>, <TextNode: '\n        <script type="te'>]>}]
2024-10-23 16:15:20,749 [DEBUG] django.db.backends: (0.000) SELECT "django_admin_log"."id", "django_admin_log"."action_time", "django_admin_log"."user_id", "django_admin_log"."content_type_id", "django_admin_log"."object_id", "django_admin_log"."object_repr", "django_admin_log"."action_flag", "django_admin_log"."change_message", "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined", "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_admin_log" INNER JOIN "auth_user" ON ("django_admin_log"."user_id" = "auth_user"."id") LEFT OUTER JOIN "django_content_type" ON ("django_admin_log"."content_type_id" = "django_content_type"."id") ORDER BY "django_admin_log"."action_time" DESC LIMIT 21; args=(); alias=default
2024-10-23 16:15:20,749 [DEBUG] django.template: Exception while resolving variable 'grappelli_admin_title' in template 'admin/index.html'.
Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 883, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/context.py", line 85, in __getitem__
    raise KeyError(key)
KeyError: 'grappelli_admin_title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 889, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(
                                            ^^^^^^^^
AttributeError: type object 'RequestContext' has no attribute 'grappelli_admin_title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 899, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'grappelli_admin_title'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 906, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [grappelli_admin_title] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: <function csrf.<locals>._get_val at 0x1085ab1a0>>, 'request': <WSGIRequest: GET '/admin/'>, 'user': <SimpleLazyObject: <User: myUser>>, 'perms': PermWrapper(<SimpleLazyObject: <User: myUser>>), 'messages': <FallbackStorage: request=<WSGIRequest: GET '/admin/'>>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}}, {}, {'site_title': 'Django site admin', 'site_header': 'Django administration', 'site_url': '/', 'has_permission': True, 'available_apps': [{'name': 'Authentication and Authorization', 'app_label': 'auth', 'app_url': '/admin/auth/', 'has_module_perms': True, 'models': [{'model': <class 'django.contrib.auth.models.Group'>, 'name': 'Groups', 'object_name': 'Group', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'view_only': False}, {'model': <class 'django.contrib.auth.models.User'>, 'name': 'Users', 'object_name': 'User', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/user/', 'add_url': '/admin/auth/user/add/', 'view_only': False}]}], 'is_popup': False, 'is_nav_sidebar_enabled': True, 'log_entries': <QuerySet []>, 'title': 'Site administration', 'subtitle': None, 'app_list': [{'name': 'Authentication and Authorization', 'app_label': 'auth', 'app_url': '/admin/auth/', 'has_module_perms': True, 'models': [{'model': <class 'django.contrib.auth.models.Group'>, 'name': 'Groups', 'object_name': 'Group', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'view_only': False}, {'model': <class 'django.contrib.auth.models.User'>, 'name': 'Users', 'object_name': 'User', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/user/', 'add_url': '/admin/auth/user/add/', 'view_only': False}]}], 'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False}, {'block': <Block Node: header. Contents: [<TextNode: '\n            <!-- HEADER '>, <Block Node: header-class. Contents: []>, <TextNode: '">\n                '>, <IfNode>, <TextNode: '\n            </header>\n  '>]>}, {'block': <Block Node: navigation. Contents: [<TextNode: '\n                        '>, <Block Node: branding. Contents: []>, <TextNode: '\n                        '>, <Block Node: admin_title. Contents: [<TextNode: '\n                        '>, <django.templatetags.i18n.TranslateNode object at 0x10867a110>, <TextNode: '\n                        '>, <IfNode>, <TextNode: '\n                        '>]>, <TextNode: '\n                        '>, <Block Node: user-tools. Contents: [<TextNode: '\n                        '>, <IfNode>, <TextNode: '\n                        '>]>, <TextNode: '\n                        '>, <Block Node: nav-global. Contents: []>, <TextNode: '\n                        '>]>}, {'block': <Block Node: admin_title. Contents: [<TextNode: '\n                        '>, <django.templatetags.i18n.TranslateNode object at 0x10867a110>, <TextNode: '\n                        '>, <IfNode>, <TextNode: '\n                        '>]>, 'vanilla_site_header': 'Django administration'}]
2024-10-23 16:15:20,750 [DEBUG] django.template: Exception while resolving variable 'original_user' in template 'admin/index.html'.
Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 883, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/contrib/sessions/backends/base.py", line 55, in __getitem__
    return self._session[key]
           ~~~~~~~~~~~~~^^^^^
KeyError: 'original_user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SessionStore' object has no attribute 'original_user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 899, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'original_user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 906, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [original_user] in <django.contrib.sessions.backends.db.SessionStore object at 0x1085fbc50>
2024-10-23 16:15:20,751 [DEBUG] django.template: Exception while resolving variable 'original_user' in template 'admin/index.html'.
Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 883, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/contrib/sessions/backends/base.py", line 55, in __getitem__
    return self._session[key]
           ~~~~~~~~~~~~~^^^^^
KeyError: 'original_user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 893, in _resolve_lookup
    current = getattr(current, bit)
              ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SessionStore' object has no attribute 'original_user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 899, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'original_user'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 906, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [original_user] in <django.contrib.sessions.backends.db.SessionStore object at 0x1085fbc50>
2024-10-23 16:15:20,752 [DEBUG] django.db.backends: (0.000) SELECT "django_admin_log"."id", "django_admin_log"."action_time", "django_admin_log"."user_id", "django_admin_log"."content_type_id", "django_admin_log"."object_id", "django_admin_log"."object_repr", "django_admin_log"."action_flag", "django_admin_log"."change_message", "auth_user"."id", "auth_user"."password", "auth_user"."last_login", "auth_user"."is_superuser", "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name", "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active", "auth_user"."date_joined", "django_content_type"."id", "django_content_type"."app_label", "django_content_type"."model" FROM "django_admin_log" INNER JOIN "auth_user" ON ("django_admin_log"."user_id" = "auth_user"."id") LEFT OUTER JOIN "django_content_type" ON ("django_admin_log"."content_type_id" = "django_content_type"."id") ORDER BY "django_admin_log"."action_time" DESC LIMIT 21; args=(); alias=default
2024-10-23 16:15:20,751 [DEBUG] django.template: Exception while resolving variable 'custom_list' in template 'admin/index.html'.
Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 883, in _resolve_lookup
    current = current[bit]
              ~~~~~~~^^^^^
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/context.py", line 85, in __getitem__
    raise KeyError(key)
KeyError: 'custom_list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 889, in _resolve_lookup
    if isinstance(current, BaseContext) and getattr(
                                            ^^^^^^^^
AttributeError: type object 'RequestContext' has no attribute 'custom_list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 899, in _resolve_lookup
    current = current[int(bit)]
                      ^^^^^^^^
ValueError: invalid literal for int() with base 10: 'custom_list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/myUser/PycharmProjects/djangoProject/.venv/lib/python3.11/site-packages/django/template/base.py", line 906, in _resolve_lookup
    raise VariableDoesNotExist(
django.template.base.VariableDoesNotExist: Failed lookup for key [custom_list] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: '0bOxjFFow4GxrXBE33Q556o5tjluIsbsbexnf44Xgg1L2dXfH1ZNw8VPLvrgwWN8'>, 'request': <WSGIRequest: GET '/admin/'>, 'user': <SimpleLazyObject: <User: myUser>>, 'perms': PermWrapper(<SimpleLazyObject: <User: myUser>>), 'messages': <FallbackStorage: request=<WSGIRequest: GET '/admin/'>>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}}, {}, {'site_title': 'Django site admin', 'site_header': 'Django administration', 'site_url': '/', 'has_permission': True, 'available_apps': [{'name': 'Authentication and Authorization', 'app_label': 'auth', 'app_url': '/admin/auth/', 'has_module_perms': True, 'models': [{'model': <class 'django.contrib.auth.models.Group'>, 'name': 'Groups', 'object_name': 'Group', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'view_only': False}, {'model': <class 'django.contrib.auth.models.User'>, 'name': 'Users', 'object_name': 'User', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/user/', 'add_url': '/admin/auth/user/add/', 'view_only': False}]}], 'is_popup': False, 'is_nav_sidebar_enabled': True, 'log_entries': <QuerySet []>, 'title': 'Site administration', 'subtitle': None, 'app_list': [{'name': 'Authentication and Authorization', 'app_label': 'auth', 'app_url': '/admin/auth/', 'has_module_perms': True, 'models': [{'model': <class 'django.contrib.auth.models.Group'>, 'name': 'Groups', 'object_name': 'Group', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/group/', 'add_url': '/admin/auth/group/add/', 'view_only': False}, {'model': <class 'django.contrib.auth.models.User'>, 'name': 'Users', 'object_name': 'User', 'perms': {'add': True, 'change': True, 'delete': True, 'view': True}, 'admin_url': '/admin/auth/user/', 'add_url': '/admin/auth/user/add/', 'view_only': False}]}], 'LANGUAGE_CODE': 'en-us', 'LANGUAGE_BIDI': False}, {'block': <Block Node: content. Contents: [<TextNode: '\n    <div class="g-d-c">\n'>, <ForNode: for app in app_list, tail_len: 9>, <TextNode: '\n            '>, <Block Node: custom_views. Contents: [<TextNode: '\n                '>, <IfNode>, <TextNode: '\n            '>]>, <TextNode: '\n        </div>\n        <'>, <django.templatetags.i18n.TranslateNode object at 0x108656790>, <TextNode: '</h2>\n                <di'>, <django.templatetags.i18n.TranslateNode object at 0x108656910>, <TextNode: '</h3>\n                   '>, <GetAdminLog Node>, <TextNode: '\n                    '>, <IfNode>, <TextNode: '\n                </div>\n '>]>}, {'block': <Block Node: custom_views. Contents: [<TextNode: '\n                '>, <IfNode>, <TextNode: '\n            '>]>}]

This currently happens in a completely new project with nothing installed and no code. All I did was install grappelli. Without grappelli, no error is logged.

Settings:

"""
Django settings for djangoProject project.

Generated by 'django-admin startproject' using Django 5.1.2.

For more information on this file, see
https://docs.djangoproject.com/en/5.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/5.1/ref/settings/
"""

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/5.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-4%*&)$xx(f%f2(e89&tl+d-_lb-o%x4tk*e-!#9qgccf(0z@)('

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

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'grappelli',
    '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',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'djangoProject.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates']
        ,
        '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 = 'djangoProject.wsgi.application'


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

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


# Password validation
# https://docs.djangoproject.com/en/5.1/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/5.1/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/5.1/howto/static-files/

STATIC_URL = 'static/'

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

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

LOGGING = {
    "version": 1,
    "disable_existing_loggers": False,
    "formatters": {
        "console": {
            "format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s",
        },
    },
    "handlers": {
        "console": {
            "class": "logging.StreamHandler",
            "formatter": "console",
        },
    },
    "loggers": {
        "django": {
            "handlers": ["console"],
            "level": "DEBUG" if DEBUG else "INFO",
            "propagate": False,
        },
        "root": {
            "handlers": ["console"],
            "level": "DEBUG" if DEBUG else "INFO",
        },
    },
}

It doesn't look like it's breaking anything but it's clogging our logs and besides, having lingering exceptions is never a good thing.

Ofc, adding the following silences the exceptions since they are at the DEBUG level:

        "django.template": {
            "handlers": ["console"],
            "level": "ERROR",
            "propagate": False,
        },

Still, I would prefer not having to silence the template errors altogether just because I'm using the grappelli package.

@petpevjp
Copy link

I'm experiencing the same issue, were you able to resolve it?

@jonasN5
Copy link
Author

jonasN5 commented Nov 21, 2024

I'm experiencing the same issue, were you able to resolve it?

So far i'm stuck with silencing the logs.

Repository owner deleted a comment from lamorrisc Nov 25, 2024
@sehmaschine
Copy link
Owner

I'm able to reproduce this with when DEBUG is True (but not when it is False). But yes, if we try to resolve a variable which does not exist an exception is thrown. But that's intended behaviour, isn't it?

https://docs.djangoproject.com/en/5.1/ref/templates/api/#how-invalid-variables-are-handled

@jonasN5
Copy link
Author

jonasN5 commented Nov 25, 2024

Well in that case we should not try to get invalid variables in DEBUG.
I don't think logging a bunch of exceptions simply because DEBUG is set to true is acceptable.

@sehmaschine
Copy link
Owner

Seems acceptable to me, but I see your point. So if someone wants to send a pull-request, we'll take a look at it.

@Emptty0
Copy link

Emptty0 commented Nov 29, 2024

/templates/admin/base.html

@@ -40,7 +40,7 @@
-        {% if debug %}
+        {% comment %} {% if debug %} {% endcomment %}

@@ -54,10 +54,10 @@

-        {% else %}
+        {% comment %} {% else %} {% endcomment %}

-        {% endif %}
+        {% comment %} {% endif %} {% endcomment %}

@@ -86,8 +86,8 @@

-                                    {% elif grappelli_admin_title %}
-                                        {{ grappelli_admin_title }}
+                                    {% comment %} {% elif grappelli_admin_title %}
+                                        {{ grappelli_admin_title }} {% endcomment %}

@@ -99,8 +99,10 @@

-                                            <li class="grp-user-options-container grp-collapse grp-closed {% if request.session.original_user %}grp-switch-user-is-target{% endif %}">
-                                                <a href="javascript://" class="user-options-handler grp-collapse-handler {% if request.session.original_user %}grp-switch-user-is-target{% else %}grp-switch-user-is-original{% endif %}">{% firstof us
er.get_short_name user.get_username %}</a>
+                                            {% comment %} <li class="grp-user-options-container grp-collapse grp-closed {% if request.session.original_user %}grp-switch-user-is-target{% endif %}">
+                                                <a href="javascript://" class="user-options-handler grp-collapse-handler {% if request.session.original_user %}grp-switch-user-is-target{% else %}grp-switch-user-is-original{% endif %}">{% firstof us
er.get_short_name user.get_username %}</a> {% endcomment %}
+                                                <li class="grp-user-options-container grp-collapse grp-closed grp-switch-user-is-target">
+                                                    <a href="javascript://" class="user-options-handler grp-collapse-handler grp-switch-user-is-target grp-switch-user-is-original">{% firstof user.get_short_name user.get_username %}</a>            

/templates/admin/change_list.html

@@ -211,18 +211,19 @@
-    <form id="grp-changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %}
+    <form id="grp-changelist-form" action="" method="post" enctype="multipart/form-data" novalidate>{% csrf_token %}
+    {% comment %} <form id="grp-changelist-form" action="" method="post"{% if cl.formset.is_multipart %} enctype="multipart/form-data"{% endif %} novalidate>{% csrf_token %} {% endcomment %}

-            {% if cl.formset.errors %}
+            {% comment %} {% if cl.formset.errors %}

-            {% endif %}
+            {% endif %} {% endcomment %}

@Emptty0
Copy link

Emptty0 commented Nov 29, 2024

@sehmaschine django grappelli it's greatest ever job over django admin panel.
I'm not a programmer, but I admire your feat. Thank you for your time. Good health for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants