2007年09月21日 星期五 15:48
我装的版本 Python 2.5 Django 0.96 使用from django.shortcuts import render_to_response的时候报错 Traceback (most recent call last): File "E:\Python\Lib\site-packages\django\core\servers\basehttp.py", line 272, in run self.result = application(self.environ, self.start_response) File "E:\Python\Lib\site-packages\django\core\servers\basehttp.py", line 614, in __call__ return self.application(environ, start_response) File "E:\Python\Lib\site-packages\django\core\handlers\wsgi.py", line 193, in __call__ response = middleware_method(request, response) File "E:\Python\Lib\site-packages\django\middleware\common.py", line 59, in process_response if response.status_code == 404: AttributeError: 'tuple' object has no attribute 'status_code' 我的代码是:list.py #coding=utf-8 from django.shortcuts import render_to_response address = [ {"name":"张三", "address":"这里是张三的地址"}, {"name":"李四", "address":"这里是李四的地址"} ] def index(request): return render_to_response("list.html"), {"address":address} 模板是:templates/list.html http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> http://www.w3.org/1999/xhtml">Django for list
2007年09月21日 星期五 16:00
return render_to_response('list.html', {'address': address}) À¨ºÅ´íÁË On 9/21/07, Singo Huang <singochina在gmail.com> wrote: > > ÎÒ×°µÄ°æ±¾ > Python 2.5 > Django 0.96 > > ʹÓÃfrom django.shortcuts import render_to_responseµÄʱºò±¨´í > > Traceback (most recent call last): > > return render_to_response('list.html', {'address': address}) > File "E:\Python\Lib\site-packages\django\core\servers\basehttp.py", > line 272, in run > self.result = application(self.environ, self.start_response) > > File "E:\Python\Lib\site-packages\django\core\servers\basehttp.py", > line 614, in __call__ > return self.application(environ, start_response) > > File "E:\Python\Lib\site-packages\django\core\handlers\wsgi.py", > line 193, in __call__ > response = middleware_method(request, response) > > File "E:\Python\Lib\site-packages\django\middleware\common.py", line > 59, in process_response > if response.status_code == 404: > > AttributeError: 'tuple' object has no attribute 'status_code' > > ÎҵĴúÂëÊÇ£ºlist.py > #coding=utf-8 > from django.shortcuts import render_to_response > > address = [ > {"name":"ÕÅÈý", "address":"ÕâÀïÊÇÕÅÈýµÄµØÖ·"}, > {"name":"ÀîËÄ", "address":"ÕâÀïÊÇÀîËĵĵØÖ·"} > ] > > def index(request): > return render_to_response("list.html"), {"address":address} > > Ä£°åÊÇ£ºtemplates/list.html > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > http://www.w3.org/1999/xhtml"> > > >Django for list > > > >> {% for user in address %} >
{{ user.name }}--{{ user.address}} > {% endfor %} > > > > > > ¸Õ½Ó´¥Django£¬²»½âÊÇʲôÎÊÌâ > _______________________________________________ > 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/20070921/80947e6e/attachment.html
Zeuux © 2025
京ICP备05028076号