2007年04月23日 星期一 17:33
ÎÒµÄmodels.py: pic = models.FileField(upload_to='%Y/%m') Ôõ Ñù¸øÉÏ´«µÄͼƬÖØÃüÃû£¿ÀýÈ磺ÒÔµ±Ê±µÄʱ¼ä¸øͼƬÃüÃû. -- ÈËÉú¾ÍÏñÒ»¸öÆ¿×Ó£¬¶øÉú»î¾ÍÊÇÆ¿×ÓÀïµÄË®¡£ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070423/b273e6a7/attachment.htm
2007年04月23日 星期一 18:05
自定义定义 FileField: class MyFileField(models.FileField): def get_filename(self, filename): # 参数是上次文件本来的名字,返回服务器上完整文件名 On 4/23/07, xiaoyi tian <purpen.w at gmail.com> wrote: > > 我的models.py: > pic = models.FileField(upload_to='%Y/%m') > 怎 样给上传的图片重命名?例如:以当时的时间给图片命名. > > -- > 人生就像一个瓶子,而生活就是瓶子里的水。 > _______________________________________________ > 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://codeplayer.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070423/b1ff27a7/attachment.html
2007年04月23日 星期一 18:05
自定义定义 FileField: class MyFileField(models.FileField): def get_filename(self, filename): # 参数是上传的文件本来的名字,返回服务器上完整文件名 刚才写错一个字。 -- http://codeplayer.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070423/761534d3/attachment.htm
2007年04月23日 星期一 18:34
ÔÚmodels.pyÀïÔõÑùµ÷ÓÃÕâ¸ö×Ô¶¨ÒåµÄFileField.»¹ÒªÔټ̳ÐÕâ¸öÀàÂ𣿠ÔÚ07-4-23£¬»ÆÒã <yi.codeplayer在gmail.com> дµÀ£º > > ×Ô¶¨Ò嶨Òå FileField£º > class MyFileField(models.FileField): > def get_filename(self, filename): > # ²ÎÊýÊÇÉÏ´«µÄÎļþ±¾À´µÄÃû×Ö£¬·µ»Ø·þÎñÆ÷ÉÏÍêÕûÎļþÃû > > ¸Õ²Åд´íÒ»¸ö×Ö¡£ > > -- > http://codeplayer.blogspot.com/ > > _______________________________________________ > 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/20070423/d77e98eb/attachment.html
2007年04月24日 星期二 09:09
On 4/23/07, xiaoyi tian <purpen.w at gmail.com> wrote: > > 在models.py里怎样调用这个自定义的FileField.还要再继承这个类吗? class SomeModel(models.Model): pic = MyFileField(upload_to='%Y/%m') 在07-4-23,黄毅 <yi.codeplayer at gmail.com> 写道: > > > > 自定义定义 FileField: > > class MyFileField(models.FileField): > > def get_filename(self, filename): > > # 参数是上传的文件本来的名字,返回服务器上完整文件名 > > > > 刚才写错一个字。 > > > > -- > > http://codeplayer.blogspot.com/ > > > > _______________________________________________ > > 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 > > > > > > -- > 人生就像一个瓶子,而生活就是瓶子里的水。 > _______________________________________________ > 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://codeplayer.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070424/d3975874/attachment.html
2007年04月24日 星期二 10:10
àÞ£¬ÕâÑù°¡£¬¶àл¡£¡£¡£ ÔÚ07-4-24£¬»ÆÒã <yi.codeplayer在gmail.com> дµÀ£º > > On 4/23/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > > > ÔÚmodels.pyÀïÔõÑùµ÷ÓÃÕâ¸ö×Ô¶¨ÒåµÄFileField.»¹ÒªÔټ̳ÐÕâ¸öÀàÂ𣿠> > > class SomeModel(models.Model): > pic = MyFileField(upload_to='%Y/%m') > > -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070424/7bae8594/attachment.htm
2007年04月24日 星期二 14:19
On 4/24/07, xiaoyi tian <purpen.w在gmail.com> wrote: > 噢,这样啊,多谢。。。 > > 在07-4-24,黄毅 <yi.codeplayer在gmail.com> 写道: > > > > On 4/23/07, xiaoyi tian <purpen.w在gmail.com > wrote: > > > 在models.py里怎样调用这个自定义的FileField.还要再继承这个类吗? > > > > > > class SomeModel(models.Model): > > pic = MyFileField(upload_to='%Y/%m') > > 使用save_FOO方法时会让你输入一个文件名的。upload_to只是设置了目录,没有文件名。 -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年04月24日 星期二 14:49
ľͷ´óÏÀ£¬save_FOO·½·¨£¬ÔõÑùÓÃÄØ£¿ÓÐÀý×ÓÂ𣿠ÔÚ07-4-24£¬limodou <limodou在gmail.com> дµÀ£º > > On 4/24/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > àÞ£¬ÕâÑù°¡£¬¶àл¡£¡£¡£ > > > > ÔÚ07-4-24£¬»ÆÒã <yi.codeplayer在gmail.com> дµÀ£º > > > > > > On 4/23/07, xiaoyi tian <purpen.w在gmail.com > wrote: > > > > ÔÚmodels.pyÀïÔõÑùµ÷ÓÃÕâ¸ö×Ô¶¨ÒåµÄFileField.»¹ÒªÔټ̳ÐÕâ¸öÀàÂ𣿠> > > > > > > > > class SomeModel(models.Model): > > > pic = MyFileField(upload_to='%Y/%m') > > > > > ʹÓÃsave_FOO·½·¨Ê±»áÈÃÄãÊäÈëÒ»¸öÎļþÃûµÄ¡£upload_toÖ»ÊÇÉèÖÃÁËĿ¼£¬Ã»ÓÐÎļþÃû¡£ > > -- > 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/20070424/450ffeb4/attachment.html
2007年04月24日 星期二 14:53
On 4/24/07, xiaoyi tian <purpen.w在gmail.com> wrote: > 木头大侠,save_FOO方法,怎样用呢?有例子吗? > 看db-api的文档: save_FOO_file(filename, raw_contents) For every FileField, the object will have a save_FOO_file() method, where FOO is the name of the field. This saves the given file to the filesystem, using the given filename. If a file with the given filename already exists, Django adds an underscore to the end of the filename (but before the extension) until the filename is available. -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou
2007年04月24日 星期二 15:06
¶àл¡£ 2007/4/24, limodou <limodou在gmail.com>: > > On 4/24/07, xiaoyi tian <purpen.w在gmail.com> wrote: > > ľͷ´óÏÀ£¬save_FOO·½·¨£¬ÔõÑùÓÃÄØ£¿ÓÐÀý×ÓÂ𣿠> > > ¿´db-apiµÄÎĵµ£º > > save_FOO_file(filename, raw_contents) > > For every FileField, the object will have a save_FOO_file() method, > where FOO is the name of the field. This saves the given file to the > filesystem, using the given filename. If a file with the given > filename already exists, Django adds an underscore to the end of the > filename (but before the extension) until the filename is available. > > > -- > 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/20070424/02b6ad00/attachment.html
Zeuux © 2025
京ICP备05028076号