update loading json - python 3.4 no more loads raw data so we need to decode it before loading to json
authorrougeronj
Wed, 18 Mar 2015 16:16:37 +0100
changeset 17 cf07ed692810
parent 16 f0f0f29395d5
child 18 4d3f67ddbe72
update loading json - python 3.4 no more loads raw data so we need to decode it before loading to json
server/ammico/views.py
--- a/server/ammico/views.py	Wed Mar 18 16:14:41 2015 +0100
+++ b/server/ammico/views.py	Wed Mar 18 16:16:37 2015 +0100
@@ -25,11 +25,11 @@
 
     #simulate the request
     r = requests.get('http://fui-ammico.jamespot.pro/api/api.php?&k=6c8bfcea247e8a5841288269887d88f0&d=2016-01-31&m=EXT-IRI&v=2.0&o=article&f=list&idUser='+user.idUser)
-    visites = json.loads(r.content)
+    visites = json.loads(r.content.decode('utf-8'))
     
     for visite in visites['VAL']:
         r = requests.get('http://fui-ammico.jamespot.pro/api/api.php?&k=6c8bfcea247e8a5841288269887d88f0&d=2016-01-31&m=EXT-IRI&v=2.0&o=article&f=get&idArticle='+visite['idArticle'])
-        visiteInfo = json.loads(r.content)['VAL']
+        visiteInfo = json.loads(r.content.decode('utf-8'))['VAL']
         book, _ = Book.objects.get_or_create(
             user=user, 
             idArticle=visiteInfo['idArticle'],
@@ -49,8 +49,6 @@
             else:
                 comment = ""
             
-            print (datetime.strptime(step['DATE'] + " " + step['TIME'], "%d/%m/%Y %H:%M:%S"))
-            
             Slide.objects.get_or_create(
                 book=book,
                 idStop=step['stop'],