theatlantic / django-generic-plus

Django model field that behaves as both a GenericForeignKey and a FileField
Other
8 stars 1 forks source link

TypeError: formfield_for_dbfield() takes 3 positional arguments but 4 were given #5

Open jayvdb opened 4 years ago

jayvdb commented 4 years ago

Running smoke tests with this added, and the following comes out many times for lots of our models. It is running on Django 3.0 on Python 3.8 I can try to narrow it down, but it is likely self explainatory.

ERROR: test_add_view (cookiecutter.tests.test_admin_smoke.AdminSiteSmokeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/django_admin_smoke_tests/tests.py", line 31, in test_deco
    fn(self, model, model_admin)
  File "/usr/lib/python3.8/site-packages/django_admin_smoke_tests/tests.py", line 265, in test_add_view
    response = model_admin.add_view(request)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1641, in add_view
    return self.changeform_view(request, None, form_url, extra_context)
  File "/usr/lib/python3.8/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1523, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 1557, in _changeform_view
    ModelForm = self.get_form(request, obj, change=not add)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 669, in get_form
    fields = flatten_fieldsets(self.get_fieldsets(request, obj))
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 328, in get_fieldsets
    return [(None, {'fields': self.get_fields(request, obj)})]
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 319, in get_fields
    form = self._get_form_for_get_fields(request, obj)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 659, in _get_form_for_get_fields
    return self.get_form(request, obj, fields=None)
  File "/usr/lib/python3.8/site-packages/django/contrib/admin/options.py", line 702, in get_form
    return modelform_factory(self.model, **defaults)
  File "/usr/lib/python3.8/site-packages/django/forms/models.py", line 554, in modelform_factory
    return type(form)(class_name, (form,), form_class_attrs)
  File "/usr/lib/python3.8/site-packages/django/forms/models.py", line 252, in __new__
    fields = fields_for_model(
  File "/usr/lib/python3.8/site-packages/django/forms/models.py", line 178, in fields_for_model
    formfield = formfield_callback(f, **kwargs)
  File "/usr/lib/python3.8/site-packages/django/contrib/gis/admin/options.py", line 63, in formfield_for_dbfield
    return super().formfield_for_dbfield(db_field, request, **kwargs)
  File "/usr/lib/python3.8/site-packages/monkeybiz/__init__.py", line 89, in wrapper
    return func(original_callable, *args, **kwargs)
TypeError: formfield_for_dbfield() takes 3 positional arguments but 4 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/django_admin_smoke_tests/tests.py", line 50, in test_deco
    six.raise_from(ModelAdminCheckException(
  File "<string>", line 3, in raise_from
django_admin_smoke_tests.tests.ModelAdminCheckException: Above exception occured while running test 'test_add_view' on modeladmin area.AreaTemplateAdmin (AreaTemplate)
dakrauth commented 3 years ago

@jayvdb We've updated the code to super Django >= 2.2. If that does not fix things, please point to your repo/branch, I was unable to find it in your fork of django-admin-smoke-tests in a super quick search.