Django - Removing extraneous unicode symbols from geraldo reports
I am using geraldo/reportlab to generate part reports on my database. Reportlab only lets me perform one queryset at a time (as I understand it.) As a result, certain aspects of my report are pulled out of Ma开发者_StackOverflow社区nyToMany fields and ForeignKeys.
For example, class band_detail in reports.py:
ObjectValue(attribute_name='number', left = 9*cm, get_value=lambda instance: Drawing.objects.filter(number=DrawingRevision.objects.filter(part__id=instance.id).values('drawing')).values_list('number', flat=True))
This displays as:
[u'1', u'2', u'3']
...and so on. I don't know how to get rid of the unicode symbol "u." I can't iterate over my lambda function in ObjectValue. I tried overriding geraldo classes and definitions such as do_before_generate(), but had no luck.
Any ideas on how to fix this? Thanks in advance!
Try:
[s.encode() for s in
ObjectValue(attribute_name='number',
left = 9*cm,
get_value=lambda instance:
Drawing.objects.filter(number=DrawingRevision.objects
.filter(part__id=instance.id)
.values('drawing')
).values_list('number', flat=True)
)
]
or
ObjectValue(attribute_name='number',
left = 9*cm,
get_value=lambda instance:
[ n.encode() for n in
Drawing.objects.filter(number=DrawingRevision.objects
.filter(part__id=instance.id)
.values('drawing')
).values_list('number', flat=True)
]
)
this should give you:
['1', '2', '3']
精彩评论