Re: Django and reportlab table question

2009-11-16 Thread Kenneth Gonsalves
On Tuesday 17 Nov 2009 11:29:25 am adelaide_mike wrote:
> Can anyone give me a push in the right direction?  Thanks for any
> help.
> 

practical example:
http://bitbucket.org/gopalasivam/fida/src/tip/web/views.py

line 194 onwards (not necessarily good code, but there are a lot of things 
like different languages, types etc.
-- 
regards
Kenneth Gonsalves
Senior Project Officer
NRC-FOSS
http://nrcfosshelpline.in/web/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Re: Django and reportlab table question

2009-11-16 Thread Andy McKay
On 09-11-16 9:59 PM, adelaide_mike wrote:
> I am attempting to user ReportLab with Django to make a report
> displaying my data in a tabular format.
[..]
>  ['Conclusion','Run!']

Loop through your vehicles as your simple naive start, eg:

data = []
for vehicle in vehicles:
 data.append([vehicle.ve_name, vehicle.ve_type])

Then expand. Looping through your query set and your models is pretty 
much the same be it reportlab or not.
-- 
   Andy McKay, @clearwind
   Training: http://clearwind.ca/training/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Django and reportlab table question

2009-11-16 Thread adelaide_mike
I am attempting to user ReportLab with Django to make a report
displaying my data in a tabular format.

An example model is:

class Vehicle(models.Model):
ve_name = models.CharField(max_length=20)
ve_type = models.CharField(max_length=20)

My report generating view a copy of the example in the ReportLab
docs.  I have marked my sticking point with '''

def testX(request):
# Our container for 'Flowable' objects
elements = []
# A large collection of style sheets pre-made for us
styles = getSampleStyleSheet()

# A basic document for us to write to 'rl_hello_table.pdf'
doc = SimpleDocTemplate('rl_hello_table.pdf')

elements.append(Paragraph("Vehicle Summary", styles['Title']))

vehicles = Vehicle.objects.all()

'''the question is how to modify the following lines to read the data
from vehicles rather than use the hard coded data shown in the
example'''

 data = [['Caves', 'Wumpus Population'],
['Deep Ditch',50],
['Death Gully',   5000],
['Dire Straits',  600],
['Deadly Pit',5],
['Conclusion','Run!']]

'''after that, I think I can sort out the following'''
# First the top row, with all the text centered and in Times-Bold,
# and one line above, one line below.
ts = [('ALIGN', (1,1), (-1,-1), 'CENTER'),
('LINEABOVE', (0,0), (-1,0), 1, colors.purple),
('LINEBELOW', (0,0), (-1,0), 1, colors.purple),
('FONT', (0,0), (-1,0), 'Times-Bold'),

# The bottom row has one line above, and three lines below of
# various colors and spacing.
('LINEABOVE', (0,-1), (-1,-1), 1, colors.purple),
('LINEBELOW', (0,-1), (-1,-1), 0.5, colors.purple, 1, None,
None, 4,1),
('LINEBELOW', (0,-1), (-1,-1), 1, colors.red),
('FONT', (0,-1), (-1,-1), 'Times-Bold')]

# Create the table with the necessary style, and add it to the
# elements list.
table = Table(data, style=ts)
elements.append(table)

Can anyone give me a push in the right direction?  Thanks for any
help.

Mike

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.