﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29347	InternalError at /admin/foo/bar/taz/change/  Error in python: TypeError DETAIL:  a float is required	rvernica	nobody	"I get the following error when accessing the detail page of my model in /admin/:

{{{
InternalError at /admin/foo/bar/taz/change/

Error in python: TypeError
DETAIL:  a float is required

}}}

The model is:

{{{
class Bar(models.Model):
    id = models.CharField(max_length=128, primary_key=True)
    modify_date = models.DateTimeField('date modified')
    change_date = models.DateTimeField('date changed')
    a = models.CharField(max_length=61)
    b = models.CharField(max_length=61)

    def __str__(self):
        return ""{}:{}"".format(self.wafer, self.location)

class BarAdmin(admin.ModelAdmin):
    fields = ('id', 'modify_date', 'change_date', 'a', 'b')
    readonly_fields = ('id', 'modify_date', 'change_date', 'a', 'b')
    list_display = ('id', 'a', 'b', 'modify_date', 'change_date')
}}}

The backend is PostgreSQL 10 and the table used by the model is a Foreign Data Wrapper table. The list page works fine, it is just the detail page that is causing issues. Here is the table schema:

{{{
CREATE FOREIGN TABLE django.foo_bar (
    id          VARCHAR(128),
    modify_date TIMESTAMP,
    change_date TIMESTAMP,
    a       VARCHAR(61),
    b    VARCHAR(61)
) SERVER filesystem OPTIONS (...);
}}}

Here is the complete traceback:


{{{
Request Method: GET
Request URL: http://cessna.labs.hpicorp.net:8000/admin/foo/bar/taz/change/

Django Version: 2.0.2
Python Version: 3.6.3
Installed Applications:
['internal.apps.InternalConfig',
 'sers.apps.SersConfig',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.postgres',
 'prettyjson']
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']



Traceback:

File ""/usr/lib/python3.6/site-packages/django/db/backends/utils.py"" in _execute
  85.                 return self.cursor.execute(sql, params)

The above exception (Error in python: TypeError
DETAIL:  a float is required
) was the direct cause of the following exception:

File ""/usr/lib/python3.6/site-packages/django/core/handlers/exception.py"" in inner
  35.             response = get_response(request)

File ""/usr/lib/python3.6/site-packages/django/core/handlers/base.py"" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File ""/usr/lib/python3.6/site-packages/django/core/handlers/base.py"" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File ""/usr/lib/python3.6/site-packages/django/contrib/admin/options.py"" in wrapper
  574.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File ""/usr/lib/python3.6/site-packages/django/utils/decorators.py"" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File ""/usr/lib/python3.6/site-packages/django/views/decorators/cache.py"" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)

File ""/usr/lib/python3.6/site-packages/django/contrib/admin/sites.py"" in inner
  223.             return view(request, *args, **kwargs)

File ""/usr/lib/python3.6/site-packages/django/contrib/admin/options.py"" in change_view
  1556.         return self.changeform_view(request, object_id, form_url, extra_context)

File ""/usr/lib/python3.6/site-packages/django/utils/decorators.py"" in _wrapper
  62.             return bound_func(*args, **kwargs)

File ""/usr/lib/python3.6/site-packages/django/utils/decorators.py"" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File ""/usr/lib/python3.6/site-packages/django/utils/decorators.py"" in bound_func
  58.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File ""/usr/lib/python3.6/site-packages/django/contrib/admin/options.py"" in changeform_view
  1450.             return self._changeform_view(request, object_id, form_url, extra_context)

File ""/usr/lib/python3.6/site-packages/django/contrib/admin/options.py"" in _changeform_view
  1471.             obj = self.get_object(request, unquote(object_id), to_field)

File ""/usr/lib/python3.6/site-packages/django/contrib/admin/options.py"" in get_object
  719.             return queryset.get(**{field.name: object_id})

File ""/usr/lib/python3.6/site-packages/django/db/models/query.py"" in get
  397.         num = len(clone)

File ""/usr/lib/python3.6/site-packages/django/db/models/query.py"" in __len__
  254.         self._fetch_all()

File ""/usr/lib/python3.6/site-packages/django/db/models/query.py"" in _fetch_all
  1179.             self._result_cache = list(self._iterable_class(self))

File ""/usr/lib/python3.6/site-packages/django/db/models/query.py"" in __iter__
  53.         results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)

File ""/usr/lib/python3.6/site-packages/django/db/models/sql/compiler.py"" in execute_sql
  1064.             cursor.execute(sql, params)

File ""/usr/lib/python3.6/site-packages/django/db/backends/utils.py"" in execute
  100.             return super().execute(sql, params)

File ""/usr/lib/python3.6/site-packages/django/db/backends/utils.py"" in execute
  68.         return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File ""/usr/lib/python3.6/site-packages/django/db/backends/utils.py"" in _execute_with_wrappers
  77.         return executor(sql, params, many, context)

File ""/usr/lib/python3.6/site-packages/django/db/backends/utils.py"" in _execute
  85.                 return self.cursor.execute(sql, params)

File ""/usr/lib/python3.6/site-packages/django/db/utils.py"" in __exit__
  89.                 raise dj_exc_value.with_traceback(traceback) from exc_value

File ""/usr/lib/python3.6/site-packages/django/db/backends/utils.py"" in _execute
  85.                 return self.cursor.execute(sql, params)

Exception Type: InternalError at /admin/foo/bar/taz/change/
Exception Value: Error in python: TypeError
DETAIL:  a float is required
}}}

"	Bug	closed	contrib.admin	2.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
