Foros del Web » Programando para Internet » Python »

[SOLUCIONADO] Error cannot concatenate 'str' and 'dict' objects al utilizar chartit de django

Estas en el tema de Error cannot concatenate 'str' and 'dict' objects al utilizar chartit de django en el foro de Python en Foros del Web. Hola amigos, Estoy intentando utilizar chartit para hacer gráficos en django. Tengo definido lo siguiente: models.py class datos_extraidos(models.Model): id_serie = models.IntegerField(primary_key=True) clave = models.IntegerField() valor ...
  #1 (permalink)  
Antiguo 27/04/2016, 08:47
 
Fecha de Ingreso: noviembre-2015
Mensajes: 9
Antigüedad: 8 años, 5 meses
Puntos: 0
Error cannot concatenate 'str' and 'dict' objects al utilizar chartit de django

Hola amigos,

Estoy intentando utilizar chartit para hacer gráficos en django. Tengo definido lo siguiente:

models.py
class datos_extraidos(models.Model):

id_serie = models.IntegerField(primary_key=True)
clave = models.IntegerField()
valor = models.IntegerField()
subclave = models.CharField(max_length=8)

class Meta:
db_table = u'datos_extraidos'

views.py
def graficas(request):
try:
bd = MySQLdb.connect("localhost","root","","gestion")
cursor = bd.cursor(MySQLdb.cursors.DictCursor)
cursor = bd.cursor()
cursor.execute("CALL gestion.dofp_muestra_datos_semanales(16)")
resultado = cursor.fetchall()
cursor.close()


ds = DataPool(series=[{'options': {'source': datos_extraidos.objects.filter(id_serie=63)}, 'terms': ['clave', 'valor']}])
cht = Chart(datasource=ds, series_options = [{'options':{'type':'line', 'stacking': False }, 'terms':{'clave': ['valor']}}], chart_options = {'title': {'text': 'Datos arrojados'},'xAxis': {'title': {'text': 'Semanas'}}})

except MySQLdb.Error, e:
print "Mysql Error %d: %s" % (e.args[0], e.args[1])


return render_to_response({'weatherchart': cht})

table.html
{% extends "bootstrap/layouts/12.html" %}

{% load django_tables2 %}
{% load chartit %}
{{ weatherchart|load_charts:"container" }}
{% block all %}


<script src="{{STATIC_URL}}js/perfilado/utils.js" ></script>
<script src="{{STATIC_URL}}js/perfilado/utils_UOBase.js" ></script>
<script type="text/javascript" src="{{STATIC_URL}}js/jquery-latest.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}js/jquery-1.7.1.js"></script>
<script type="text/javascript" src="{{STATIC_URL}}js/highcharts/js/highcharts.js"></script>

<body>
<div id='container'> Chart will be rendered here </div>
</body>


El error que me está arrojando es: cannot concatenate 'str' and 'dict' objects

Alguien sabe que puede estar sucediendo?
Muchas gracias,
  #2 (permalink)  
Antiguo 03/05/2016, 08:17
 
Fecha de Ingreso: noviembre-2015
Mensajes: 9
Antigüedad: 8 años, 5 meses
Puntos: 0
Respuesta: Error cannot concatenate 'str' and 'dict' objects al utilizar chartit de d

Hola de nuevo,

Por si alguna vez le pasa a alguien más, la solución fue fácil. Sustituí el render to response por render.

Muchas gracias,
Un saludo,

Etiquetas: django
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 02:23.