Ver Mensaje Individual
  #7 (permalink)  
Antiguo 07/06/2010, 09:36
Alex_10
 
Fecha de Ingreso: junio-2009
Mensajes: 10
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: Escoger datos de las clases modelos

Tienes razon amigo, me habia leido otro manual, mira, ahora modifique el metodo y me da este error: 'Manager' object has no attribute 'raw'. Estoy buscando a ver como lo soluciono, mientras le pongo el metodo a ver si me puede ayudar, saludos Alexander

Este es el metodo:

Código Python:
Ver original
  1. def excelejemplo(request):     
  2.     personas=Tribunal.objects.raw('SELECT presidente,secretario FROM tesis_tribunal')  
  3.     simple_report=ExcelReport()
  4.     simple_report.addSheet("Prueba sencilla")  
  5.     simple_report.addQuerySet(personas,REPORT_HORZ)
  6.     response = HttpResponse(simple_report.writeReport(),mimetype='application/ms-excel')
  7.         response['Content-Disposition'] = 'attachment; filename=simple_test.xls'
  8.         return response

Aqui debajo pongo la informacion completa del error por si sirve de ayuda


AttributeError at /tesis/reporte/

'Manager' object has no attribute 'raw'

Request Method: GET
Request URL: http://localhost/tesis/reporte/
Exception Type: AttributeError
Exception Value:

'Manager' object has no attribute 'raw'

Exception Location: e:\Tesis\sigaweb\tesis\views.py in excelejemplo, line 590
Python Executable: C:\Python26\python.exe
Python Version: 2.6.3
Python Path: ['e:\\Tesis\\sigaweb', 'C:\\Python26\\lib\\site-packages\\django_excel_templates-0.1-py2.6.egg', 'C:\\Python26\\lib\\site-packages\\simplejson-2.1.1-py2.6.egg', 'C:\\WINDOWS\\system32\\python26.zip', 'C:\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win', 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-packages', 'C:\\Python26\\lib\\site-packages\\PIL']
Server time: lun, 7 Jun 2010 11:02:33 +0200
Traceback Switch to copy-and-paste view

* C:\Python26\lib\site-packages\django\core\handlers\base.py in get_response
85. # Apply view middleware
86. for middleware_method in self._view_middleware:
87. response = middleware_method(request, callback, callback_args, callback_kwargs)
88. if response:
89. return response
90.
91. try:
92. response = callback(request, *callback_args, **callback_kwargs) ...
93. except Exception, e:
94. # If the view raised an exception, run it through exception
95. # middleware, and if the exception middleware returns a
96. # response, use that. Otherwise, reraise the exception.
97. for middleware_method in self._exception_middleware:
98. response = middleware_method(request, e)
▶ Local vars
Variable Value
callback
<function excelejemplo at 0x018F5D30>
callback_args
()
callback_kwargs
{}
e
AttributeError("'Manager' object has no attribute 'raw'",)
exc_info
(<type 'exceptions.AttributeError'>, AttributeError("'Manager' object has no attribute 'raw'",), <traceback object at 0x0154C878>)
exceptions
<module 'django.core.exceptions' from 'C:\Python26\lib\site-packages\django\core\exceptions.pyc'>
middleware_method
<bound method AuthenticationMiddleware.process_request of <django.contrib.auth.middleware.AuthenticationMidd leware object at 0x015B2BD0>>
receivers
[(<function _rollback_on_exception at 0x011EDD30>, None)]
request
<WSGIRequest GET:<QueryDict: {}>, POST:<QueryDict: {}>, COOKIES:{'sessionid': 'd9229436856e73d1501ae31aa7453503'}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\\All Users', 'APPDATA': 'C:\\Documents and Settings\\Alex\\Datos de programa', 'CLIENTNAME': 'APTO56102', 'COMMONPROGRAMFILES': 'C:\\Archivos de programa\\Archivos comunes', 'COMPUTERNAME': 'UCI-A9E57B275A5', 'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'text/plain', 'DJANGO_SETTINGS_MODULE': 'sigaweb.settings', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents and Settings\\Alex', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'es-es,es;q=0.8,en-us;q=0.5,en;q=0.3', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=d9229436856e73d1501ae31aa7453503', 'HTTP_HOST': 'localhost', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://localhost/tesis/Buscar_Tribunal/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5', 'LOGONSERVER': '\\\\UCI-A9E57B275A5', 'NUMBER_OF_PROCESSORS': '2', 'OS': 'Windows_NT', 'PATH': 'C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\Sy stem32\\Wbem;C:\\Archivos de programa\\Intel\\DMIX;C:\\Archivos de programa\\Microsoft SQL Server\\90\\Tools\\binn\\;C:\\AppServ\\Apache2.2\\ bin;C:\\AppServ\\php6;C:\\AppServ\\MySQL\\bin;C:\\ Python26;C:\\Python26\\Lib\\site-packages;C:\\Python26\\Lib\\site-packages\\django\\bin;C:\\MiPrimeraWeb;C:\\Django; C:\\MiPrimeraWeb;C:\\Django\\django\\contrib\\auth ', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH' , 'PATH_INFO': u'/tesis/reporte/', 'PGLOCALEDIR': 'C:\\Archivos de programa\\PostgreSQL\\8.2\\share\\locale', 'PROCESSOR_ARCHITECTURE': 'x86', 'PROCESSOR_IDENTIFIER': 'x86 Family 15 Model 4 Stepping 3, GenuineIntel', 'PROCESSOR_LEVEL': '15', 'PROCESSOR_REVISION': '0403', 'PROGRAMFILES': 'C:\\Archivos de programa', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_HOST': '', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': u'', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.1 Python/2.6.3', 'SESSIONNAME': 'RDP-Tcp#1', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP': 'C:\\DOCUME~1\\Alex\\CONFIG~1\\Temp', 'TMP': 'C:\\DOCUME~1\\Alex\\CONFIG~1\\Temp', 'USERDOMAIN': 'UCI-A9E57B275A5', 'USERNAME': 'Alex', 'USERPROFILE': 'C:\\Documents and Settings\\Alex', 'WINDIR': 'C:\\WINDOWS', 'WINGDB_ACTIVE': '1', 'WINGDB_PYTHON': 'C:\\Python26\\python.exe', 'WINGDB_SPAWNCOOKIE': 'z9BfwWWvolzIJrD3', 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x00AB40C0>, 'wsgi.file_wrapper': <class 'django.core.servers.basehttp.FileWrapper'>, 'wsgi.input': <socket._fileobject object at 0x01503EB0>, 'wsgi.multiprocess': False, 'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}>
resolver
<RegexURLResolver sigaweb.urls (None:None) ^/>
response
None
self
<django.core.handlers.wsgi.WSGIHandler object at 0x01504D90>
settings
<django.conf.LazySettings object at 0x00E6E830>
urlconf
'sigaweb.urls'
urlresolvers
<module 'django.core.urlresolvers' from 'C:\Python26\lib\site-packages\django\core\urlresolvers.pyc'>
* e:\Tesis\sigaweb\tesis\views.py in excelejemplo
583. #date_style = xlwt.easyxf(num_format_str='dd/mm/yyyy')
584. #formato=ExcelFormatter()
585. #estilosimple = ExcelStyle(vert=2,wrap=1)
586. #formato.addBodyStyle(estilosimple)
587. #formato.setWidth('presidente,secretario,',3000)
588. def excelejemplo(request):
589. lista = Tribunal.objects.all()
590. personas=Tribunal.objects.raw('SELECT presidente,secretario FROM tesis_tribunal') ...
591. ##cursor=connection.cursor()
592. #cursor.execute("SELECT presidente,secretario FROM tesis_tribunal")
593. #row=cursor.fetchall()
594. simple_report=ExcelReport()
595. simple_report.addSheet("Prueba sencilla")
596. simple_report.addQuerySet(personas,REPORT_HORZ)
▶ Local vars

Última edición por AlvaroG; 07/06/2010 a las 10:36 Razón: arreglar coloreado de código