[Django] #29347: InternalError at /admin/foo/bar/taz/change/ Error in python: TypeError DETAIL: a float is required

19 views
Skip to first unread message

Django

unread,
Apr 20, 2018, 6:39:51 PM4/20/18
to django-...@googlegroups.com
#29347: InternalError at /admin/foo/bar/taz/change/ Error in python: TypeError
DETAIL: a float is required
-----------------------------------------+------------------------
Reporter: rvernica | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 2.0
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 |
-----------------------------------------+------------------------
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
}}}

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

Django

unread,
Apr 20, 2018, 8:23:36 PM4/20/18
to django-...@googlegroups.com
#29347: InternalError at /admin/foo/bar/taz/change/ Error in python: TypeError
DETAIL: a float is required
-------------------------------+--------------------------------------

Reporter: rvernica | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 2.0
Severity: Normal | Resolution:

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 Tim Graham):

It's not clear to me that Django is at fault. Have you confirmed that and
if so, can you explain what the problem is? Is that error coming from
PostgreSQL? I'm not familiar with foreign data wrappers.

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

Django

unread,
Apr 23, 2018, 8:57:17 AM4/23/18
to django-...@googlegroups.com
#29347: InternalError at /admin/foo/bar/taz/change/ Error in python: TypeError
DETAIL: a float is required
-------------------------------+--------------------------------------
Reporter: rvernica | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0
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 Tim Graham):

* status: new => closed
* type: Uncategorized => Bug
* resolution: => needsinfo


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

Django

unread,
Apr 23, 2018, 4:38:57 PM4/23/18
to django-...@googlegroups.com
#29347: InternalError at /admin/foo/bar/taz/change/ Error in python: TypeError
DETAIL: a float is required
-------------------------------+--------------------------------------
Reporter: rvernica | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0
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 rvernica):

You are correct the exception was coming from PostgreSQL Foreign Data
Wrapper which is also written in Python. Django was just propagating the
error. It confused me quite a bit since I had not idea where it was
braking from Django's trace. Upon seeing the PostgreSQL log, it was all
clear. Just for completeness, this is the error trace in PostgreSQL. Sorry
for the hassle.

{{{
2018-04-23 18:19:17.913 UTC [30] ERROR: Error in python: TypeError
2018-04-23 18:19:17.913 UTC [30] DETAIL: Traceback (most recent call
last):

File "/usr/local/lib/python2.7/dist-
packages/multicorn-1.3.4.dev0-py2.7-linux-
x86_64.egg/multicorn/fsfdw/__init__.py", line 272, in execute
return self.items_to_dicts(self.get_items(quals, columns),
columns)

File "/usr/local/lib/python2.7/dist-
packages/multicorn-1.3.4.dev0-py2.7-linux-
x86_64.egg/multicorn/fsfdw/__init__.py", line 279, in get_items
unicode_(qual.value))

File "/usr/local/lib/python2.7/dist-
packages/multicorn-1.3.4.dev0-py2.7-linux-
x86_64.egg/multicorn/fsfdw/structuredfs.py", line 373, in from_filename
return Item(self, values)

File "/usr/local/lib/python2.7/dist-
packages/multicorn-1.3.4.dev0-py2.7-linux-
x86_64.egg/multicorn/fsfdw/structuredfs.py", line 195, in __init__
self.mtime = datetime.datetime.fromtimestamp(mtime)

TypeError: a float is required
}}}

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

Django

unread,
Apr 23, 2018, 10:30:25 PM4/23/18
to django-...@googlegroups.com
#29347: InternalError at /admin/foo/bar/taz/change/ Error in python: TypeError
DETAIL: a float is required
-------------------------------+--------------------------------------
Reporter: rvernica | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 2.0
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 Tim Graham):

* resolution: needsinfo => invalid


--
Ticket URL: <https://code.djangoproject.com/ticket/29347#comment:4>

Reply all
Reply to author
Forward
0 new messages