Fresh Docker development environment throws builtins.KeyError
See original GitHub issueAfter many a try with fresh installation (removed all Docker containers, images, and volumes, rm -rf project_name) Django container invariably throws:
builtins.KeyError
KeyError: 'common'
while visiting /
,/about
,/users
,/accounts
, Django admin pages work as expected.
Running on Mac OS X 11.11.6 Docker Version 1.12.0-a (build: 11213) Cookiecutter version: 1.4.0 Local Python Version: 3.5.2 Pip Version: 8.1.2 Cookiecutter settings:
{
"cookiecutter":{
"use_celery":"y",
"use_pycharm":"n",
"use_lets_encrypt":"y",
"use_docker":"y",
"domain_name":"REDACTED",
"use_python3":"y",
"version":"0.1.0",
"use_mailhog":"y",
"author_name":"REDACTED",
"use_compressor":"n",
"use_sentry_for_error_reporting":"y",
"windows":"n",
"use_opbeat":"n",
"postgresql_version":"9.5",
"project_slug":"REDACTED",
"timezone":"CET",
"description":"REDACTED",
"js_task_runner":"Webpack",
"email":"REDACTED",
"use_whitenoise":"y",
"project_name":"REDACTED",
"use_heroku":"n",
"open_source_license":"Not open source"
}
}
Docker Compose Log:
django_1 | KeyError: 'common'
django_1 | 172.18.0.1 - - [31/Aug/2016 07:03:46] "GET /?__debugger__=yes&cmd=pinauth&pin=423-615-454&s=aAGA2m6dMKNSU22Hbgw1 HTTP/1.1" 500 -
django_1 | Traceback (most recent call last):
django_1 | File "/usr/local/lib/python3.5/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
django_1 | return self.application(environ, start_response)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 177, in __call__
django_1 | response = self.get_response(request)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 230, in get_response
django_1 | response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
django_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 289, in handle_uncaught_exception
django_1 | return debug.technical_500_response(request, *exc_info)
django_1 | File "/usr/local/lib/python3.5/site-packages/django_extensions/management/technical_response.py", line 6, in null_technical_500_response
django_1 | six.reraise(exc_type, exc_value, tb)
django_1 | File "/usr/local/lib/python3.5/site-packages/six.py", line 686, in reraise
django_1 | raise value
django_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 174, in get_response
django_1 | response = self.process_exception_by_middleware(e, request)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py", line 172, in get_response
django_1 | response = response.render()
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/response.py", line 160, in render
django_1 | self.content = self.rendered_content
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/response.py", line 137, in rendered_content
django_1 | content = template.render(context, self._request)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/backends/django.py", line 95, in render
django_1 | return self.template.render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 206, in render
django_1 | return self._render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/test/utils.py", line 92, in instrumented_test_render
django_1 | return self.nodelist.render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 992, in render
django_1 | bit = node.render_annotated(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 959, in render_annotated
django_1 | return self.render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/loader_tags.py", line 173, in render
django_1 | return compiled_parent._render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/test/utils.py", line 92, in instrumented_test_render
django_1 | return self.nodelist.render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 992, in render
django_1 | bit = node.render_annotated(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 959, in render_annotated
django_1 | return self.render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/loader_tags.py", line 69, in render
django_1 | result = block.nodelist.render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 992, in render
django_1 | bit = node.render_annotated(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/base.py", line 959, in render_annotated
django_1 | return self.render(context)
django_1 | File "/usr/local/lib/python3.5/site-packages/django/template/library.py", line 201, in render
django_1 | output = self.func(*resolved_args, **resolved_kwargs)
django_1 | File "/usr/local/lib/python3.5/site-packages/webpack_loader/templatetags/webpack_loader.py", line 40, in render_bundle
django_1 | return render_as_tags(_get_bundle(bundle_name, extension, config), attrs)
django_1 | File "/usr/local/lib/python3.5/site-packages/webpack_loader/templatetags/webpack_loader.py", line 32, in _get_bundle
django_1 | bundle = get_loader(config).get_bundle(bundle_name)
django_1 | File "/usr/local/lib/python3.5/site-packages/webpack_loader/loader.py", line 79, in get_bundle
django_1 | chunks = assets['chunks'][bundle_name]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5
Top Results From Across the Web
Fresh Docker development environment throws builtins.KeyError
After many a try with fresh installation (removed all Docker containers, images, and volumes, rm -rf project_name) Django container ...
Read more >Python throws KeyError when exporting environment variables
It seems that you're meant to set environment variables for a Docker session using built-in Dockerfile functionality.
Read more >Get started with development Containers in Visual Studio Code
First your image is built from the supplied Docker file or image name. Then a container is created and started using some of...
Read more >[Solved]-Python throws KeyError when exporting environment ...
Coding example for the question Python throws KeyError when exporting environment variables-docker.
Read more >AWS Cloud Development Kit (AWS CDK) v2 - Developer Guide
AWS Cloud Development Kit (AWS CDK) v2: Developer Guide ... Configure with properties and methods, not environment variables . ... Built-in help ....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve run into the same problem and this is what I’ve surmised of the issue:
There are only two entry points defined in the Webpack configuration file (main and vendor). In the base.html template there are references to three bundles (main, vendor and common). Since there is no common bundle, you get the KeyError you’re experiencing.
The fix is to remove
{% render_bundle 'common' %}
from the template file.@jimbofreedman no, I haven’t. This is not limited to Docker environment. I have set up a fresh project with local development environment and Webpack. Same error, but this time more debug information: