import urllib
from django.http import HttpResponse
def output_file(request, file, mimetype):
f = urllib.urlopen(file)
data = f.read()
f.close()
return HttpResponse(data, mimetype=mimetype)
It is better to serve from static environments but sometimes, you want
to check user righ
Generally that's done by spitting out some custom headers;
Content-Type: text/pdf
Content-Disposition: attachment; filename=yourfilename.pdf
That way most browsers will give you the option to open or to save-
as. To do that does require that they're sent dynamically, but as
said before it'd b
Besides, i want to revise my first question as:
How to serve static file by "pushing" a PDF to client? In php, there
is a way to serve PDF by pushing the file to the client, and client to
choose "Save As" or "Open" the file directly.
Adobe reader is very slow if they run in browsers, and most of
Thanks Ben,
Besides, i've found that www.lawrence.com and www.ljworld.com (which
are famous sites that use django) use a http://media.their-domain-name.com
to store the media files.
All static files, images, css are from the http://media.their-domain-name.com
server. Obviously the media subdomain
You're better off not doing it with Django, just make a directory
that won't be handled by Django and stick all your static content in
there. After all, the webserver is usually better at serving static
files than Django is :)
On 17/07/2007, at 2:26 PM, Arnold Chen wrote:
>
> Can any one
Can any one please tell me how to serve a static PDF in django ? The
file is located in the server, and do not need to be created on the
fly (by using report lab). I have done it in PHP by using header, but
i just don't know how to do it with django. Thanks
--~--~-~--~~~-
6 matches
Mail list logo