Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53972 > unrolled thread
| Started by | pestrella@gmail.com |
|---|---|
| First post | 2013-09-11 08:04 -0700 |
| Last post | 2013-09-11 17:09 +0000 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.python
TypeError in date_parse.py pestrella@gmail.com - 2013-09-11 08:04 -0700
Re: TypeError in date_parse.py John Gordon <gordon@panix.com> - 2013-09-11 16:15 +0000
Re: TypeError in date_parse.py pestrella@gmail.com - 2013-09-11 10:02 -0700
Re: TypeError in date_parse.py John Gordon <gordon@panix.com> - 2013-09-11 17:09 +0000
| From | pestrella@gmail.com |
|---|---|
| Date | 2013-09-11 08:04 -0700 |
| Subject | TypeError in date_parse.py |
| Message-ID | <09d39e02-c741-4a46-b34f-551e11118e7b@googlegroups.com> |
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']
[toc] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2013-09-11 16:15 +0000 |
| Message-ID | <l0q4u5$i1t$1@reader1.panix.com> |
| In reply to | #53972 |
In <09d39e02-c741-4a46-b34f-551e11118e7b@googlegroups.com> pestrella@gmail.com writes:
> =============================
> # 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?
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
[toc] | [prev] | [next] | [standalone]
| From | pestrella@gmail.com |
|---|---|
| Date | 2013-09-11 10:02 -0700 |
| Message-ID | <3d0038fd-00ec-4560-ab0d-06528f838026@googlegroups.com> |
| In reply to | #53975 |
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'],
[toc] | [prev] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2013-09-11 17:09 +0000 |
| Message-ID | <l0q83f$l1f$1@reader1.panix.com> |
| In reply to | #53978 |
In <3d0038fd-00ec-4560-ab0d-06528f838026@googlegroups.com> pestrella@gmail.com writes:
> 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'],
That's a list, containing a string. float() expects a single item, not a
list.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web