django写网站的时候出现的一些错误

unsupported operand type(s) for *: 'float' and 'NoneType'

在 * 这个符号不支持float和NoneType运算,多数为左右两边变量有问题(上面这个就是左边float类型,右边NoneType型无法运算)

(1062, "Duplicate entry '132' for key 'PRIMARY'") 

无法重复写入主键为132的 数据,通常是在model.py中写了super.save()方法然后又在save方法中再因为某些逻辑重新super.save()一次……也就是说

def save()内出现了两次super.save()

 

"Upload a valid image. The file you uploaded was either not an image or a corrupted image." 

这个不是异常,是form的提示,对应中文为:您所上传的文件不是图片或者是已损坏的图片

正确的上传图片都会出现这个,网上的解决方案为install libjpeg libjepg-dev,试过,无效!

后来我换了一个python版本,行了,出现这个问题时用的是python2.5

后来用python2.6就没有这个问题了! 


ModelForm has no model class specified. 

在继承了ModelForm的Form中没有加上

class Meta:

     model=你的model 

 

TypeError: super() argument 1 must be type, not classobj 


通常是因为old class 引起的。在基类上写上

class baseclass(object)即可 

 

UnboundLocalError at /test/shopInfo

local variable 'obj' referenced before assignment 

 

未绑定的本地错误。

本地变量 obj 在指派前被引用。

通常就是未在上文声明obj变量,但是却在在下文引用了 

如以下逻辑

if None:

    obj=111

else :

    print obj;//出错。 

 

错误'IOError: sys.stdout access restricted by mod_wsgi' 

l

A: A portable WSGI application or application component should not output anything to standard output. This is because some WSGI hosting mechanisms use standard output to communicate with the web server. If a WSGI application outputs anything to standard output it will thus potentially interleave with the response sent back to the client. 
To promote portability of WSGI applications, mod_wsgi by default restricts direct use of 'sys.stdout' and 'sys.stdin'. Because the 'print' statement defaults to outputing text to 'sys.stdout', using 'print' for debugging purposes can cause this error.
 

 

 

意思就是项目中不能出现print打印语句,需要删除

 The 'avatar' attribute has no file associated with it.

原型是这样的:  raise ValueError("The '%s' attribute has no file associated with 
it." % self.field.name) 

avatar属性 没有相关的文件。

意思就是avatar这个属性,没有上传文件。

通常发生在,model中的imagefield字段没有设定为blank=True,不可空的属性必须赋值才能写入数据库,否则出错 

 

 

UnicodeEncodeError: 'ascii' codec can't encode characters in position 70-74: ordinal not in range(128) 

 

这个问题极度恶心,如果不是运气好,还真没有办法解决。http://stackoverflow.com/questions/4398540/unicodeencodeerror-when-saving-imagefield-containing-non-ascii-characters-in-dja/8342356#8342356 

https://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-you-get-a-unicodeencodeerror 

 

n linux:

echo $LANG i got zh_CN.UTF-8

in apache2/envvars

export LANG='zh_CN.UTF-8' #keep this variable like echo  $LANG.

export LC_ALL='zh_CN.UTF-8' #the same.

 

继续遇到继续添加 

 

 

转载于:https://www.cnblogs.com/snowleung/archive/2011/08/31/2161387.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值