小编Gio*_*Bot的帖子

'module'对象没有属性'now'将尝试创建CSV

你好我导入到csv有问题,我得到了这个错误,问题是我有相同的代码在其他机器上运行,它运行完美.我缺少什么,我需要为此安装其他库?

def exportar_a_csv_grl(request):
    #Fecha actual
    hoy = datetime.now().date()
    #Creado el:
    creado_hoy = hoy.strftime("%m/%d/%Y")
    response = HttpResponse(mimetype='text/csv')
    response['Content-Disposition'] = 'attachment;filename="Reporte de Miembros ' +      creado_hoy + '.csv"'
response['Content-Type'] = 'text/csv; charset=utf-8'
response.write("\xEF\xBB\xBF")

writer = csv.writer(response)
miembros = Miembro.objects.all().extra(select={'miem_monto': "aplicacionmediexcel_miembro_monto.monto"},
                                       tables=["aplicacionmediexcel_miembro_monto"], where=[
        """aplicacionmediexcel_miembro.id=aplicacionmediexcel_miembro_monto.miembro_id"""])
#.extra(select = {'precio':'''select aplicacionmediexcel_miembro_monto.monto from aplicacionmediexcel_miembro_monto, aplicacionmediexcel_miembro where  aplicacionmediexcel_miembro.id = aplicacionmediexcel_miembro_monto.miembro_id'''})
miembros_colec = Miembro_colec.objects.all().extra(
    select={'miem_monto': "aplicacionmediexcel_colectivo_miembro_monto.monto"},
    tables=["aplicacionmediexcel_colectivo_miembro_monto"],
    where=["""aplicacionmediexcel_miembro_colec.id=aplicacionmediexcel_colectivo_miembro_monto.miembro_colec_id"""])
dependientes = Dependiente.objects.all()
dependientes_colec = Dependiente_colec.objects.all()
writer.writerow(['Creado el:             ' + creado_hoy + ' '])
writer.writerow([''])
#csv_data = (
#   ('ID Miembro', …
Run Code Online (Sandbox Code Playgroud)

python csv django django-views

23
推荐指数
2
解决办法
6万
查看次数

'ascii'编解码器无法对位置9中的字符u'\ u2013'进行编码:序数不在范围内(128)

我正在尝试导入到cvs,但是我收到了这个错误

UnicodeEncodeError at /brokers/csv/'ascii' codec can't encode character u'\u2013' in position 9: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)

Unicode错误提示

无法编码/解码的字符串是:)758-9800

我试过.encode,unicode()等没有任何作用,我不知道我是否需要一个库或其他东西,因为我在其他机器上有相同的代码并且工作正常.

 def exportar_a_csv_brokers(request):
     #Fecha actual
     hoy = datetime.now().date()
     #Creado el:
     creado_hoy = hoy.strftime("%m/%d/%Y")
     response = HttpResponse(mimetype='text/csv')
     response['Content-Disposition'] = 'attachment;filename=
     "Reporte de Brokers ' +  creado_hoy + '.csv"'
     response['Content-Type'] = 'text/csv; charset=utf-8'
     response.write("\xEF\xBB\xBF")

     writer = csv.writer(response)
     brokers = Broker.objects.all()
     writer.writerow(['Creado el:             ' + creado_hoy + ' '])
     writer.writerow([''])
     writer.writerow(
    ['Apellido Paterno', 'Nombre', '# Broker', '# Licencia de Seguro', 'ID Federal',  'Nombre Agencia', 'Teléfono', …
Run Code Online (Sandbox Code Playgroud)

python csv django export

7
推荐指数
2
解决办法
2万
查看次数

使用Jquery从日期获取星期几?

我现在已经是aswer之前,问题是我从输入的日期不是当前日期.

我需要得到一周的一天.目前我得到这种格式的日期:

11/09/2013
Run Code Online (Sandbox Code Playgroud)

但我希望它像:

Saturday/02/2013. 
Run Code Online (Sandbox Code Playgroud)

我正在使用datepicker来显示日历,所以它可能是一些解决方案,可以帮助我使用相同的插件.

javascript jquery

5
推荐指数
1
解决办法
2万
查看次数

从jquery更改日期格式

我有这个约会,我从jquery得到

Wed Oct 30 2013 09:05:17 GMT-0800 (Hora estándar Pacífico (México))
Run Code Online (Sandbox Code Playgroud)

我得到了这个功能

var date = new Date();
var newdate = new Date(date);
newdate.setDate(newdate.getDate() + 7);
var nd = new Date(newdate);
$('#vigencia_receta_11').val(nd);
Run Code Online (Sandbox Code Playgroud)

但我只需要日期而不是时间,我想格式化日期,如"DD/MM/YYYY"

format jquery date

4
推荐指数
1
解决办法
4万
查看次数

Reportlab新线在长线上

在此输入图像描述

我需要一个新行,所以我可以在PFD中看到一种格式,我尝试添加页面宽度,但它没有工作,我使用/ n的其他东西,它不起作用.这是我的代码.我可以手动添加一个格式,因为我需要显示从数据库获取的信息,并在一个长行中获取信息.

def PdfReportView(request):
    print id
    # Create the HttpResponse object with the appropriate PDF headers.
    response = HttpResponse(content_type='application/pdf')
    response['Content-Disposition'] = 'filename="PatientReport.pdf"'
    c = canvas.Canvas(response, pagesize=letter)
    t = c.beginText()
    t.setFont('Helvetica-Bold', 10)
    t.setCharSpace(3)
    t.setTextOrigin(50, 700)
    t.textLine("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.")
    c.drawText(t)
    c.showPage()
    c.save() …
Run Code Online (Sandbox Code Playgroud)

python pdf newline reportlab

2
推荐指数
1
解决办法
4083
查看次数

标签 统计

python ×3

csv ×2

django ×2

jquery ×2

date ×1

django-views ×1

export ×1

format ×1

javascript ×1

newline ×1

pdf ×1

reportlab ×1