[BangPypers] Dynamic color for table column (color stored in model)

Gora Mohanty gora at mimirtech.com
Thu Nov 17 10:51:39 CET 2011


On Thu, Nov 17, 2011 at 7:03 AM, kracekumar ramaraju
<kracethekingmaker at gmail.com> wrote:
[...]
> One advice is use css to set colors.In your template check for color value
> ="red" and then render css for that colour, else if you are using only 2
> colour you can  even and odd property.
[...]

Reportlab generates PDF, which is presumably served to the user from
a Django view. I do not think that CSS can be used here.

Asif, have you looked at the reportlab documentation? You should be
able to use BACKGROUND, and TEXTCOLOR to set the colours,
choosing the appropriate colour from a model field. Please see
chapter 7 of the Reportlab user guide:
http://www.reportlab.com/docs/reportlab-userguide.pdf

This blog might also help:
http://www.blog.pythonlibrary.org/2010/09/21/reportlab-tables-creating-tables-in-pdfs-with-python/
It is the first result from searching Google for +reportlab +tables.

Regards,
Gora


More information about the BangPypers mailing list