TypeError in date_parse.py


P

pestrella

Hello, I'm running an application using python 2.7 with django 1.5 and when posting a page I get the error "TypeError" I guess it is something related to timestamps?
Below I paste part of the code I think is causing the problem and the stacktace I see

Any help is welcome, Thanks!
Paula

=============================
# Compute duration for this item.
duration = None
if end_timestamp and start_timestamp:
start_datetime = datetime.fromtimestamp(float(start_timestamp))
end_datetime = datetime.fromtimestamp(float(end_timestamp))
duration = end_datetime - start_datetime
=============================
POST
Request URL: http://127.0.0.1:8000/appraise/evaluation/7b31d05e50584d2b92b4a04d85e68ce3/
Django Version: 1.5.2
Exception Type: TypeError
Exception Value:
expected string or buffer
Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/dateparse.py in parse_time, line 50
Python Executable: /usr/bin/python
Python Version: 2.7.2
Python Path:
['../Appraise-Software/appraise',
'/home/paula/.local/lib/python2.7/site-packages/setuptools-1.1.4-py2.7.egg',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/home/paula/.local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
 
Ad

Advertisements

J

John Gordon

In said:
=============================
# Compute duration for this item.
duration = None
if end_timestamp and start_timestamp:
start_datetime = datetime.fromtimestamp(float(start_timestamp))
end_datetime = datetime.fromtimestamp(float(end_timestamp))
duration = end_datetime - start_datetime
=============================

What is the type and value of start_timestamp and end_timestamp?
 
P

pestrella

I think it's a float, I see in the code

if request.method == "POST":
end_timestamp = request.POST.get('end_timestamp', None)
start_timestamp = request.POST.get('start_timestamp', None)

and in the debug of django

<QueryDict: {u'start_timestamp': [u'1378918630.398'],
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top