python3 django unicode error_django-1.3在windows系统环境下的一个出错?'SafeUnicode' object has no attribute 'sta...

1) 系统环境是:apache2.2+wsgi+mssql+python2.7+django1.3 , 配置完成后,能够正常访问到django-admin等应用

2) 在浏览器中访问http://127.0.0.1:8006/user_all/时的报错信息:AttributeError at /user_all/

'SafeUnicode' object has no attribute 'status_code'

Request Method: GET

Request URL: http://127.0.0.1:8006/user_all/

Django Version: 1.3.1

Exception Type: AttributeError

Exception Value:

'SafeUnicode' object has no attribute 'status_code'

Exception Location: C:\Python27\lib\site-packages\django\middleware\common.py in process_response, line 94

Python Executable: C:\Program Files\Apache Software Foundation\Apache2.2\bin\httpd.exe

Python Version: 2.7.2

Python Path:

['C:\\Python27\\lib\\site-packages\\pip-1.1-py2.7.egg',

'C:\\WINDOWS\\system32\\python27.zip',

'C:\\Python27\\Lib',

'C:\\Python27\\DLLs',

'C:\\Python27\\Lib\\lib-tk',

'C:\\Program Files\\Apache Software Foundation\\Apache2.2',

'C:\\Program Files\\Apache Software Foundation\\Apache2.2\\bin',

'C:\\Python27',

'C:\\Python27\\lib\\site-packages',

'C:\\Python27\\lib\\site-packages\\win32',

'C:\\Python27\\lib\\site-packages\\win32\\lib',

'C:\\Python27\\lib\\site-packages\\Pythonwin',

'D:/wind1/']

Server time: 星期四, 5 七月 2012 17:06:52 +0800

3) settings的数据库配置:(数据库引擎采用的是django-mssql)DATABASES = {

'default': {

###'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.

'ENGINE': 'sqlserver_ado',

'NAME': 'django', # Or path to database file if using sqlite3.

'USER': 'django', # Not used with sqlite3.

'PASSWORD': 'django', # Not used with sqlite3.

'HOST': '', # Set to empty string for localhost. Not used with sqlite3.

'PORT': '', # Set to empty string for default. Not used with sqlite3.

}

}

4) urls中的URL映射:url(r'user_all/$', 'mysite.polls.views.django_user_all'),

5) views中的视图函数:def django_user_all(request):

from django.contrib.auth.models import User

entry_list = User.objects.values()[0].all()

html = "

{%for tmp in entry_list%} {{tmp}} {%endfor%}

"

t = Template(html)

c = Context(entry_list)

return t.render(c)

6) 希望大家指出问题所在。谢谢了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值