4.28 JEE实习日记

需要理解  Django_Excel 函数里面参数的意义 ,仔细阅读下面的 文章 

链接 :http://django-excel.readthedocs.io/en/latest/

明天需要 处理的是 1 日本那边的数据 是怎么分的 ,下载的数据类型是什么样子的

  2 数据列 确定以后做成 policy 形式 ,这个 我觉得参考 auth 那个会比较好!!,分层进行表示

  3 view 里面import 的数据 需要不同的列名称 ,所以 应该还要 把对应 列名传到 view 里面  


def export_datas(request,atype):

    if atype == "sheet":
        def choice_func(row):
            print row[0]
            q = Question.objects.filter(slug=row[0])[0]
            row[0] = q
            return row
        models=[
                    (Question, ['question_text', 'pub_date', 'slug'], None, 0),  
                    (Choice, ['question_happp', 'choice_text', 'votes'], choice_func, 0)
                 ]
        #这边 Model涉及到Model层的改动吧?,Choice和 Question 分别 代表 sheet 的名字 
        return excel.make_response_from_a_table(
            Question, 'xls', file_name="sheet_test")
    elif atype == "book":
        return excel.make_response_from_tables(
            [Property], 'xls', file_name="book")
    elif atype == "custom":
        Propertys = Property.objects.get(slug='ide')
        column_names = ['NameUnicode','Latitude','Longitude','ProjectArea','YearBuilt','LandArea','PropertyTypeName','RecordStartDate','RecordEndDate','view_flag','control_flag']
        return excel.make_response_from_query_sets(
            Propertys,
            column_names,
            'xls',
            file_name="custom"
        )
    else :
        message_for_add_result = "fail"
        return render_to_response('property/view.html',{'message_for_add_result': message_for_add_result}, context_instance = RequestContext(request))
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值