[Django] #32017: TypeError: check() got an unexpected keyword argument 'databases'

6 views
Skip to first unread message

Django

unread,
Sep 18, 2020, 6:09:21 AM9/18/20
to django-...@googlegroups.com
#32017: TypeError: check() got an unexpected keyword argument 'databases'
------------------------------------------------+------------------------
Reporter: Stian Jensen | Owner: nobody
Type: Bug | Status: new
Component: Core (System checks) | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
When updating from django 3.0.10 to 3.1.0 (also 3.1.1), I get a new error
when running management commands that involve running system checks.
The whole stack trace involves only django code (no other third-party
packages), so I assume this cannot be related to other packages I have
installed.

I saw something in the release notes about a new --database flag to the
check command, but I cannot piece together if it has anything to do with
this error (Running manage.py check with '--database default' does not
remove the crash, for instance).

{{{
.venv/bin/python manage.py check
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "app/.venv/lib/python3.8/site-
packages/django/core/management/__init__.py", line 401, in
execute_from_command_line
utility.execute()
File "app/.venv/lib/python3.8/site-
packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "app/.venv/lib/python3.8/site-
packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "app/.venv/lib/python3.8/site-
packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "app/.venv/lib/python3.8/site-
packages/django/core/management/commands/check.py", line 63, in handle
self.check(
File "app/.venv/lib/python3.8/site-
packages/django/core/management/base.py", line 392, in check
all_issues = checks.run_checks(
File "app/.venv/lib/python3.8/site-
packages/django/core/checks/registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "app/.venv/lib/python3.8/site-
packages/django/core/checks/model_checks.py", line 34, in check_all_models
errors.extend(model.check(**kwargs))
File "app/.venv/lib/python3.8/site-packages/django/db/models/base.py",
line 1264, in check
*cls._check_fields(**kwargs),
File "app/.venv/lib/python3.8/site-packages/django/db/models/base.py",
line 1343, in _check_fields
errors.extend(field.check(**kwargs))
TypeError: check() got an unexpected keyword argument 'databases'
}}}
(I stripped out some of the absolute paths to file names that should be
irrelevant from the traceback)

--
Ticket URL: <https://code.djangoproject.com/ticket/32017>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 18, 2020, 6:57:08 AM9/18/20
to django-...@googlegroups.com
#32017: TypeError: check() got an unexpected keyword argument 'databases'
-------------------------------------+-------------------------------------

Reporter: Stian Jensen | Owner: nobody
Type: Bug | Status: closed
Component: Core (System | Version: 3.1
checks) |
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* status: new => closed
* resolution: => needsinfo


Comment:

Thanks for this ticket however I cannot reproduce this issue. Can you
provide a small project?

--
Ticket URL: <https://code.djangoproject.com/ticket/32017#comment:1>

Django

unread,
Sep 18, 2020, 12:01:21 PM9/18/20
to django-...@googlegroups.com
#32017: TypeError: check() got an unexpected keyword argument 'databases'
-------------------------------------+-------------------------------------

Reporter: Stian Jensen | Owner: nobody
Type: Bug | Status: closed
Component: Core (System | Version: 3.1
checks) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Stian Jensen):

Hi, after trying to make a reproduce I finally tracked down the issue in
our codebase. We have a custom model field where we've overridden the
`check` method to do some extra validation of the field config. That
method wasn't setup to take in `**kwargs`. It seems like something has
changed in django 3.1 that now sends `databases` as a kwarg, so just
changing our method signature to `check(self, **kwargs):` solved the
problem.

Thanks, and sorry for the incorrect bug report!

--
Ticket URL: <https://code.djangoproject.com/ticket/32017#comment:2>

Django

unread,
Sep 18, 2020, 12:11:27 PM9/18/20
to django-...@googlegroups.com
#32017: TypeError: check() got an unexpected keyword argument 'databases'
-------------------------------------+-------------------------------------

Reporter: Stian Jensen | Owner: nobody
Type: Bug | Status: closed
Component: Core (System | Version: 3.1
checks) |
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* resolution: needsinfo => invalid


Comment:

Thanks for checking.

--
Ticket URL: <https://code.djangoproject.com/ticket/32017#comment:3>

Reply all
Reply to author
Forward
0 new messages