Mon 15 Sep 2008

    Django-1.0-file-upload

    原因

    想通过 Django admin 做个简单的上传文件管理,遇到个问题。files = models.FileField(upload_to=('files')) 默认是把所有的文件都保存在同一个目录 files 下面,我想通过types来判断不同的类型保存到不同目录下,像这样的结构: files/types/filename.

    表结构:

    class Car(models.Model):
        name = models.CharField(max_length=255)
        types = models.CharField(max_length=255)
        files = models.FileField(upl

    (Read more...)

    Tags: Django, web, python 评论(0) 阅读(274)

    Fri 08 Aug 2008

    Django From 0.96 update to 1.0 logging

    Django升级到1.0时,发现原来写的东西就运行不起来, 去官方查了一下原来Admin和newform的API改动了, 还好这次不是大面积的改动.

    更新简单记录一下.

    本文主要参考: http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges

    admin url

    URLconfs:

    # OLD:
    from django.conf.urls.defaults import *
    
    urlpatterns = patterns('',
        (r'^admin/', include('

    (Read more...)

    Tags: Django, web, python 评论(0) 阅读(349)

    Tue 24 Jun 2008

    Extjs Tree通过递归删除子节点

    Extjs Tree通过递归删除子节点信息:

    function removeChildrenRecursively(node) {
        if (!node) return;
        while (node.hasChildNodes()) {
            removeChildrenRecursively(node.firstChild);
            node.removeChild(node.firstChild);
        }
    }
    

    参考: http://www.realcoding.net/article/view/4557

    (Read more...)

    Tags: web, javascript, Extjs 评论(1) 阅读(575)

    Tue 17 Jun 2008

    javascript对时间格式化

    JavaScript通过原型函数的封装对時間格式化函數:

    <script>
        Date.prototype.format = function(format)
        {
            var o = {
                "M+" : this.getMonth()+1, //month
                "d+" : this.getDate(),    //day
                "h+" : this.getHours(),   //hour
                "m+" : this.getMinutes(), //minute
                "s+" : this.getSeconds(), //second
                "q+" : Math.floor((this.getMonth()+3)/3), //quarter

    (Read more...)

    Tags: web, javascript 评论(1) 阅读(526)