Python论坛  - 讨论区

标题:[python-chinese] 关于django的meta.ImageField的问题~~~~

2006年05月25日 星期四 15:45

头太晕 super852 at gmail.com
Thu May 25 15:45:02 HKT 2006

#apps/user/user.py

#coding=utf-8
from django.core import meta
class User(meta.Model):
    username=meta.CharField('用户名',maxlength=50,primary_key=True,core=True)
    password=meta.CharField('密码',maxlength=50,core=True)
    email=meta.EmailField('电邮地址',db_index=True,core=True)
    nickname=meta.CharField('昵称',maxlength=30,core=True)
    regdate=meta.DateTimeField("注册时间",auto_now_add=True,core=True)
    lasttime=meta.DateTimeField("上次登录时间",auto_now=True,core=True)
    photo=meta.ImageField("用户照片",default='None.jpg
',upload_to='userphoto',height_field=240,width_field=320,core=True)
    regip=meta.IPAddressField("注册时的IP地址",core=True)
    lastip=meta.IPAddressField("上次的IP地址",core=True)
    selfname=meta.TextField("个性签名",core=True,default='-')
    def __repr__(self):
        return self.username
    class META:
        admin = meta.Admin()


我在admin里,添加一条记录,
关于ImageField会出错:

TypeError at /admin/user/users/super852/ attribute name must be string Request
Method: POST  Request URL:
http://127.0.0.1:8000/admin/user/users/super852/  Exception
Type: TypeError  Exception Value: attribute name must be string  Exception
Location: c:\python24\lib\site-packages\django-
0.91-py2.4.egg\django\core\meta\__init__.py in method_save_file, line 1305


我把height_field=240,width_field=320,这两个参数去掉,就一切正常了...


请问这是怎么回事?应该怎么改? height_field和width_field到底怎么用?


-- 
阿弥陀佛 晕哉 晕哉
--------
欢迎光临我的菜园子:
http://spaces.msn.com/members/headfaint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060525/59ba420e/attachment.htm

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

2006年05月25日 星期四 16:56

xxmplus xxmplus at gmail.com
Thu May 25 16:56:16 HKT 2006

既然要求是string,那就加个单引号试试

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

2006年05月25日 星期四 17:08

头太晕 super852 at gmail.com
Thu May 25 17:08:00 HKT 2006

改成height_field='240',width_field='320',以后.提示如下错误.

AttributeError at /admin/user/users/super852/ 'User' object has no attribute
'320' Request Method: POST  Request URL:
http://127.0.0.1:8000/admin/user/users/super852/  Exception Type:
AttributeError  Exception Value: 'User' object has no attribute '320'
Exception
Location: c:\python24\lib\site-packages\django-
0.91-py2.4.egg\django\core\meta\fields.py in save_file, line 566

在06-5-25,xxmplus <xxmplus at gmail.com> 写道:
>
> 既然要求是string,那就加个单引号试试
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
>
>


-- 
阿弥陀佛 晕哉 晕哉
--------
欢迎光临我的菜园子:
http://spaces.msn.com/members/headfaint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060525/2b982f24/attachment.htm

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

2006年05月25日 星期四 17:10

头太晕 super852 at gmail.com
Thu May 25 17:10:38 HKT 2006

limodou去哪儿了?

在06-5-25,头太晕 <super852 at gmail.com> 写道:
>
>
> 改成height_field='240',width_field='320',以后.提示如下错误.
>
> AttributeError at /admin/user/users/super852/ 'User' object has no
> attribute '320'
> Request Method: POST  Request URL:
> http://127.0.0.1:8000/admin/user/users/super852/  Exception Type:
> AttributeError  Exception Value: 'User' object has no attribute '320'  Exception
> Location: c:\python24\lib\site-packages\django-
> 0.91-py2.4.egg\django\core\meta\fields.py in save_file, line 566
>
> 在06-5-25,xxmplus <xxmplus at gmail.com> 写道:
> >
> > 既然要求是string,那就加个单引号试试
> >
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese at lists.python.cn
> > Subscribe: send subscribe to python-chinese-request at lists.python.cn
> > Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> > Detail Info: http://python.cn/mailman/listinfo/python-chinese
> >
> >
>
>
> --
> 阿弥陀佛 晕哉 晕哉
> --------
> 欢迎光临我的菜园子:
> http://spaces.msn.com/members/headfaint
>



-- 
阿弥陀佛 晕哉 晕哉
--------
欢迎光临我的菜园子:
http://spaces.msn.com/members/headfaint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060525/10ef0e6e/attachment.html

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

2006年05月25日 星期四 18:00

xxmplus xxmplus at gmail.com
Thu May 25 18:00:52 HKT 2006

google了一下,搜到这样一句话:
In the ImageField class, the width_field attribute should be holding
the *name* of the width field, not its value.

希望对你有用。

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

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

    你的回复:

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

    Zeuux © 2025

    京ICP备05028076号