Opened 8 years ago
Closed 8 years ago
#27772 closed Bug (needsinfo)
Multiple Database without Default
Reported by: | Sammie S. Taunton | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.10 |
Severity: | Normal | Keywords: | database, multiple database, default database, database router |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Following the example on https://docs.djangoproject.com/en/1.10/topics/db/multi-db/
I created 2 databases, setup the routers in the example, and tested
Data being selected appears to be working however when trying to insert OR update I'm receiving the following error:
Performing system checks... System check identified no issues (0 silenced). January 24, 2017 - 21:33:54 Django version 1.10.5, using settings 'application.settings' Starting development server at http://10.4.1.1:80/ Quit the server with CONTROL-C. Internal Server Error: /en/employee/edit Traceback (most recent call last): File "/usr/local/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 39, in inner response = get_response(request) File "/usr/local/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/python/lib/python3.6/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view return view_func(request, *args, **kwargs) File "/vhosts/admin-install/login/security/gacl.py", line 27, in _wrapper return view_func(request, *args, **kwargs) File "/vhosts/admin-install/employee/views.py", line 112, in edit result2 = ServiceEdit(request).edit(form.cleaned_data) File "/usr/local/python/lib/python3.6/contextlib.py", line 52, in inner with self._recreate_cm(): File "/usr/local/python/lib/python3.6/site-packages/django/db/transaction.py", line 158, in __enter__ if not connection.get_autocommit(): File "/usr/local/python/lib/python3.6/site-packages/django/db/backends/base/base.py", line 365, in get_autocommit self.ensure_connection() File "/usr/local/python/lib/python3.6/site-packages/django/db/backends/dummy/base.py", line 21, in complain raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details. [24/Jan/2017 21:33:58] "POST /en/employee/edit HTTP/1.1" 500 19406
This is caused by the empty 'default': {} database configuration. I copied the primary settings into the default area and now things are working. However, I'd prefer to not be forced into using the default setting, which from the documentation in a multi-db setup the default is not required to be filled out, only the key needs to be there (which is fine).
As an additional test I added print() statements to the DB Router definitions for db_for_read, db_for_write, allow_relation, and allow_migrate. This would allow me to see when the page is reloaded / submitted if the query is even passing through the router. Reads were in fact going to the router as expected, however insert/updates were not. No print statement, only the error message.
Read Test in DB Router:
Performing system checks... System check identified no issues (0 silenced). January 24, 2017 - 21:46:01 Django version 1.10.5, using settings 'application.settings' Starting development server at http://10.4.1.1:80/ Quit the server with CONTROL-C. TEST READ MESSAGE [24/Jan/2017 21:46:03] "GET /en/employee/edit HTTP/1.1" 200 74622
So based on this, I can only assume the routing is not happening properly someplace.
I'm willing to try what is needed to help resolve this.
Hi, in a case like this, it's better to ask for help on our support channels until you confirm you've identified a bug. For best results, please include a sample project that reproduces the issue. If you confirm that Django is at fault, please reopen with details. Thanks.