Forums

KeyError at / 'en-gb'

Any idea why I might be getting this error in my Django project?

here is the traceback

Environment:

Request Method: GET Request URL: https://windrider.pythonanywhere.com/

Django Version: 3.2.4 Python Version: 3.8.0 Installed Applications: ['bootstrap4', 'django_extensions', 'pages.apps.PagesConfig', 'students.apps.StudentsConfig', 'accounts.apps.AccountsConfig', 'classes', 'seating', 'teacher', 'csvimport.app.CSVImportConf', 'import_export', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] 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']

Template error: In template /home/windrider/student_tracker/templates/partials/_navbar.html, error at line 17 en-gb 7 : <a href="#" class="navbar-brand">All Hallows</a> 8 : <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse"> 9 : <span class="navbar-toggler-icon"></span> 10 : </button> 11 : 12 : <div class="collapse navbar-collapse" id="navbarCollapse"> 13 : <div class="navbar-nav"> 14 : <a href="#" class="nav-item nav-link active">Home</a> 15 : <a href="# " class="nav-item nav-link">Teachers</a> 16 : <a href="#" class="nav-item nav-link">Messages</a> 17 : <a href=" {% url 'login' %} " class="nav-item nav-link disabled" tabindex="-1">Reports</a> 18 : </div> 19 : <div class="navbar-nav ml-auto"> 20 : <a href="#" class="nav-item nav-link">Login</a> 21 : </div> 22 : </div> 23 : </nav>

Traceback (most recent call last): File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, callback_args, callback_kwargs) File "/home/windrider/student_tracker/pages/views.py", line 7, in index return render(request, 'pages/index.html') File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/shortcuts.py", line 19, in render content = loader.render_to_string(template_name, context, request, using=using) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/loader.py", line 62, in render_to_string return template.render(context, request) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/backends/django.py", line 61, in render return self.template.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 170, in render return self._render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/loader_tags.py", line 150, in render return compiled_parent._render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/loader_tags.py", line 195, in render return template.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 172, in render return self._render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 162, in _render return self.nodelist.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 938, in render bit = node.render_annotated(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/base.py", line 905, in render_annotated return self.render(context) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/template/defaulttags.py", line 446, in render url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/urls/base.py", line 86, in reverse return resolver._reverse_with_prefix(view, prefix, args, **kwargs) File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/urls/resolvers.py", line 627, in _reverse_with_prefix self._populate() File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/urls/resolvers.py", line 477, in _populate url_pattern._populate() File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/urls/resolvers.py", line 477, in _populate url_pattern._populate() File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/urls/resolvers.py", line 482, in _populate for name in url_pattern.reverse_dict: File "/home/windrider/.virtualenvs/django3/lib/python3.8/site-packages/django/urls/resolvers.py", line 513, in reverse_dict return self._reverse_dict[language_code]

Exception Type: KeyError at / Exception Value: 'en-gb'

I'd guess there's some sort of issue with your url definition for 'login'. How is that url defined?