Python论坛  - 讨论区

标题:[python-chinese] django step by step 学到第八节,遇到一个问题,求助!!

2007年04月18日 星期三 22:31

boyeestudio boyee118在gmail.com
星期三 四月 18 22:31:44 HKT 2007

 哪位遇到这个问题?求解一下,谢谢!
IndexError at /address/upload/ list index out of range  Request
Method: POST  Request
URL: http://127.0.0.1:8000/address/upload/  Exception Type: IndexError
 Exception
Value: list index out of range  Exception Location:
D:\opensource\mysite\address\views.py
in upload, line 53
Traceback (innermost last) Switch to copy-and-paste
view<http://127.0.0.1:8000/address/upload/#>


   - C:\Python24\Lib\site-packages\django\core\handlers\base.py in
   get_response
      1. # Apply view middleware
      2. for middleware_method in self._view_middleware:
      3. response = middleware_method(request, callback,
      callback_args, callback_kwargs)
      4. if response:
      5. return response
      6.
      7. try:
      1. response = callback(request, *callback_args,
      **callback_kwargs) ...
   1. except Exception, e:
      2. # If the view raised an exception, run it through exception
      3. # middleware, and if the exception middleware returns a
      4. # response, use that. Otherwise, reraise the exception.
      5. for middleware_method in self._exception_middleware:
      6. response = middleware_method(request, e)
       ▶ Local vars <http://127.0.0.1:8000/address/upload/#>
     Variable
   Value
     callback
   

    callback_args
   ()

    callback_kwargs
   {}

    debug
   

    e
   

    exceptions
   

    mail_admins
   

    middleware_method
   <
   django.middleware.doc.XViewMiddleware object at 0x0159D770>>

    request
   , POST:,
   COOKIES:{'sessionid': 'c31988bb1ffdffcd327d3c551166bcab'},
   META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\\All Users', 'APPDATA':
   'C:\\Documents and Settings\\boyeestudio\\Application Data',
   'APR_ICONV_PATH': 'C:\\Program Files\\Subversion\\iconv', 'CLASSPATH':
   '.;D:\\jdk1.4/lib/dt.jar;D:\\jdk1.4/lib/tools.jar;E:/home/qs/lib/classes12.jar;E:/home/qs/lib/commons-
   beanutils-1.6.jar;E:/home/qs/lib/commons-collections-2.1.jar
   ;E:/home/qs/lib/commons-lang-1.0-b1.jar;E:/home/qs/lib/commons-
   logging-1.0.1.jar
   ;E:/home/qs/lib/htmlparser.jar;E:/home/qs/lib/jconn2.jar;E:/home/qs/lib/jdom.jar;E:/home/qs/lib/jdom.jar_cp;E:/home/qs/lib/log4j-
   1.2.13.jar;E:/home/qs/lib/log4j-1.2.8.jar
   ;E:/home/qs/lib/lucene.jar;E:/home/qs/lib/luke.jar;E:/home/qs/lib/PDFBox-
   0.7.2.jar
   ;E:/home/qs/lib/poi.jar;E:/home/qs/lib/protomatter.jar;E:/home/qs/lib/publicmodel.jar;E:/home/qs/lib/qs.jar;E:/home/qs/lib/smroute.jar;E:/home/qs/lib/tm-
   extractors-0.2.jar;E:/home/qs/lib/compress.jar', 'COMMONPROGRAMFILES':
   'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'BOYEE', 'COMSPEC':
   'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '260', 'CONTENT_TYPE':
   'multipart/form-data; boundary=---------------------------305902726027536',
   'DJANGO_SETTINGS_MODULE': 'mysite.settings', 'DSLISTEN': 'BOYEE',
   'DSQUERY': 'BOYEE', 'DXSDK_DIR': 'C:\\Program Files\\Microsoft DirectX
   9.0 SDK (October 2005)\\', 'FP_NO_HOST_CHECK': 'NO',
   'GATEWAY_INTERFACE': 'CGI/1.1', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents
   and Settings\\boyeestudio', 'HTTP_ACCEPT':
   'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9
   ,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET':
   'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING':
   'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
   'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE':
   'sessionid=c31988bb1ffdffcd327d3c551166bcab', 'HTTP_HOST': '
   127.0.0.1:8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': '
   http://127.0.0.1:8000/address/', 'HTTP_USER_AGENT': 'Mozilla/5.0
   (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309
   Firefox/2.0.0.3', 'INCLUDE': 'C:\\Program Files\\Microsoft Visual
   Studio\\VC98\\atl\\include;C:\\Program Files\\Microsoft Visual
   Studio\\VC98\\mfc\\include;C:\\Program Files\\Microsoft Visual
   Studio\\VC98\\include', 'JAVA_HOME': 'D:\\jdk1.4', 'JSERV':
   'C:\\oracle\\ora92/Apache/Jserv/conf', 'LANG': 'zh_CN', 'LIB': 'C:\\Program
   Files\\Microsoft Visual Studio\\VC98\\mfc\\lib;C:\\Program Files\\Microsoft
   Visual Studio\\VC98\\lib', 'LM_LICENSE_FILE':
   'D:\\sybase\\SYSAM-1_0\\licenses\\license.dat', 'LOGONSERVER': '\\\\BOYEE',
   'MSDEVDIR': 'C:\\Program Files\\Microsoft Visual Studio\\Common\\MSDev98',
   'NUMBER_OF_PROCESSORS': '2', 'ORACLEPATH': 'C:\\Program
   Files\\Oracle\\jre\\1.1.8\\bin;C:\\Program Files\\Oracle\\jre\\1.3.1\\bin;',
   'OS': 'Windows_NT', 'PATH': 'C:\\Program Files\\Microsoft DirectX
9.0SDK (October
   2005)\\Utilities\\Bin\\x86;D:\\sybase\\DataAccess\\OLEDB\\dll;D:\\sybase\\DataAccess\\ODBC\\dll;D:\\sybase\\RPL-12_5\\bin;D:\\sybase\\Shared\\Sybase
   Central 4.3;D:\\sybase\\OCS-12_5\\lib3p;D:\\sybase\\OCS-12_5\\dll;D:\\sybase\\OCS-12_5\\bin;D:\\sybase\\ASE-12_5\\dll;D:\\sybase\\ASE-12_5\\bin;D:\\sybase\\DataAccess\\ADONET\\dll;D:\\sybase\\JS-12_5\\bin;D:\\sybase\\EFTS-12_5_2\\verity\\_nti40\\filters;D:\\sybase\\EFTS-12_5_2\\verity\\_nti40\\bin;D:\\sybase\\EFTS-12_5_2\\bin;D:\\sybase\\Shared\\Sybase
   Central 4.3;C:\\Program Files\\REALTEK Semiconductor
   Corporation\\REALTEK PCIE NIC Driver;c:\\ruby\\bin;C:\\Program
   Files\\REALTEK Semiconductor Corporation\\REALTEK PCIE NIC
   Driver;C:\\oracle\\ora92\\bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Python24;C:\\Program
   Files\\SecureCRT\\;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\Tools\\WinNT;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\MSDev98\\Bin;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\Tools;C:\\Program Files\\Microsoft Visual
   Studio\\VC98\\bin;C:\\Python24;D:\\jdk1.4\\bin;D:\\jdk1.4\\jre\\bin;C:\\jython2.2b1;C:\\ruby\\bin;C:\\Program
   Files\\CVSNT\\;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\Tools\\WinNT;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\MSDev98\\Bin;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\Tools;C:\\Program Files\\Microsoft Visual
   Studio\\VC98\\bin;C:\\Python24;D:\\jdk1.4\\bin;D:\\jdk1.4\\jre\\bin;C:\\jython2.2b1;C:\\ruby\\bin;C:\\Program
   Files\\CVSNT\\;C:\\Qt\\4.2.3\\bin;C:\\Dev-Cpp\\bin;C:\\Program
   Files\\WinSCP\\;C:\\Program Files\\Subversion\\bin;C:\\Program
   Files\\Subversion\\bin;C:\\gdc\\bin;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\Tools\\WinNT;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\MSDev98\\Bin;C:\\Program Files\\Microsoft Visual
   Studio\\Common\\Tools;C:\\Program Files\\Microsoft Visual
   Studio\\VC98\\bin;C:\\Python24;D:\\jdk1.4\\bin;D:\\jdk1.4\\jre\\bin;C:\\jython2.2b1;C:\\ruby\\bin;C:\\Program
   Files\\CVSNT\\;C:\\Qt\\4.2.3\\bin;C:\\Dev-Cpp\\bin;C:\\Python24\\Scripts;',
   'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.RB;.RBW',
   'PATH_INFO': '/address/upload/', 'PROCESSOR_ARCHITECTURE': 'x86',
   'PROCESSOR_IDENTIFIER': 'x86 Family 15 Model 72 Stepping 2, AuthenticAMD',
   'PROCESSOR_LEVEL': '15', 'PROCESSOR_REVISION': '4802', 'PROGRAMFILES':
   'C:\\Program Files', 'PROMPT': '$P$G', 'QMAKESPEC': 'win32-g++', 'QTDIR':
   'C:\\Qt\\4.2.3', 'QUERY_STRING': '', 'REMOTE_ADDR': '127.0.0.1',
   'REMOTE_HOST': '', 'REQUEST_METHOD': 'POST', 'RUBYOPT': '-rubygems',
   'RUN_MAIN': 'true', 'SCRIPT_NAME': '', 'SCROOT': 'D:\\sybase\\Shared\\Sybase
   Central 4.3', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8000',
   'SERVER_PROTOCOL': 'HTTP/1.1', 'SERVER_SOFTWARE': 'WSGIServer/0.1
   Python/2.4.3', 'SESSIONNAME': 'Console', 'SYBASE': 'D:\\sybase',
   'SYBASE_ASE': 'ASE-12_5', 'SYBASE_FTS': 'EFTS-12_5_2', 'SYBASE_JRE':
   'D:\\sybase\\Shared\\Sun\\jre142', 'SYBASE_JS': 'JS-12_5', 'SYBASE_OCS':
   'OCS-12_5', 'SYBASE_SYSAM': 'SYSAM-1_0', 'SYBASE_WS': 'WS-12_5', 'SYBROOT':
   'D:\\sybase', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TEMP':
   'C:\\DOCUME~1\\BOYEES~1\\LOCALS~1\\Temp', 'TMP':
   'C:\\DOCUME~1\\BOYEES~1\\LOCALS~1\\Temp', 'USERDOMAIN': 'BOYEE', 'USERNAME':
   'boyeestudio', 'USERPROFILE': 'C:\\Documents and Settings\\boyeestudio',
   'WINDIR': 'C:\\WINDOWS', 'WV_GATEWAY_CFG':
   'C:\\oracle\\ora92\\Apache\\modplsql\\cfg\\wdbsvr.app',
   'XCHAT_WARNING_IGNORE': 'true', 'wsgi.errors': ',
   mode 'w' at 0x00ACE0B0>, 'wsgi.file_wrapper': , 'wsgi.input':
   , 'wsgi.multiprocess': False,
   'wsgi.multithread': True, 'wsgi.run_once': False, 'wsgi.url_scheme':
   'http', 'wsgi.version': (1, 0)}>

    resolver
   

    response
   None

    self
   

    settings
   

    urlconf
   'mysite.urls'

    urlresolvers
   

     - D:\opensource\mysite\address\views.py in upload
      1. try:
      2. reader = csv.reader(buf)
      3. except:
      4. return render_to_response('address/error.html',
      5. {'message':'你需要上传一个csv格式的文件!'})
      6. for row in reader:
      7. # objs = Address.objects.get_list(name__exact=row[0])
   1. objs = Address.objects.filter(name=row[0]) ...
   1. if not objs:
      2. obj = Address(name=row[0], gender=row[1],
      3. telphone=row[2], mobile=row[3], room=row[4])
      4. else:
      5. obj = objs[0]
      6. obj.gender = row[1]
-------------- 下一部分 --------------
一个HTML附件被移除...
URL: http://python.cn/pipermail/python-chinese/attachments/20070418/b4f02f70/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年04月18日 星期三 22:38

limodou limodou在gmail.com
星期三 四月 18 22:38:31 HKT 2007

很有可能是列数与程序不符。



-- 
I like python!
UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年04月18日 星期三 23:07

boyeestudio boyee118在gmail.com
星期三 四月 18 23:07:08 HKT 2007

2007/4/18, limodou <limodou在gmail.com>:
>
> ºÜÓпÉÄÜÊÇÁÐÊýÓë³ÌÐò²»·û¡£


ÕæµÃÊÇÕâÑù£¬ÓÐÒ»ÐÐÁÐÊý²»¶Ô£¡
·Ç³£¸Ðл£¡

--
> I like python!
> UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad
> My Blog: http://www.donews.net/limodou
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070418/7ebcb81f/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号