On Tue, Mar 30, 2010 at 9:08 PM, Paulo Almeida
<igcbioinformat...@gmail.com> wrote:
> Ok, that is not easy to debug with so little information. Is the IndexError
> in views.py? Maybe there is a mistake in urls.py, caused by adding the url
> for the generate_pdf view?

Hm, its indeed hard. I really dont know what that Error will tell me.
My Application is a very basic one. Up to now i do everything in the
admin interface. The only url defined is the one to view the pdf file:

urls.py:
urlpatterns = patterns('',
    # Example:
    # (r'^eiwomisa/', include('eiwomisa.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
    (r'^project/task/', include('project.task.urls')),
    (r'^office/job/', include('office.job.urls')),
)

offic/job/urls.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('office.job.views',
    (r'/offer/generate/pdf/$', 'generate_pdf', '',
'office_job_generate_offer_pdf'),
)

and here is my views.py:

def generate_pdf(request):
    response = HttpResponse(mimetype='application/pdf')
    response['Content-Disposition'] = 'attachment; filename=somefilename.pdf'

    doc = BaseDocTemplate(filename=response,pagesize=A4)
    styles = getSampleStyleSheet()
    Document = [Paragraph('rd', styles["Title"])]
    Document.append(Spacer(1,50))
    date_now = unicode(datetime.now().strftime("%B %d, %Y"))
    Document.append(Paragraph("PDF created on " + date_now, styles["Normal"]))
    Document.append(Spacer(1,10))
    doc.build(Document)

I have tried the same "setup" with the canvas.Canvas example from the
django documentation, and it worked. All i changed here is from canvas
to document.

Greetings
Sven

-- 
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=en.

Reply via email to