Tuesday, May 31, 2011

Re: How to I create download link of some file using django

you are welcome!

> I have another question here. It seems that django.contrib.staticfiles
> can be used to handle some static files during the 'debug' mode while
> using the embedded 'runserver' from django. However, would it be
> possible if I just develop my website using the system's Apache and
> not using the django.contrib.staticfiles?

Of course and this is even better, because this is how the setup should be on real server.

You have to configure Apache to serve for example everything under http://mydomain.com/static/ as a simple file without talking to django at all. The static stuff is good for static files like CSS and JavaScript.

BTW: although this goes beyond the question I just want to mention it for completeness.

On the other hand the {{MEDIA_URL }} and MEDIA_ROOT is more for server/user generated files. You can still have Apache serve the file after authorizing it against Django. The keyword here is: x-sendfile

http://stackoverflow.com/questions/1156246/having-django-serve-downloadable-files

What you were doing with open the file probably only makes sense if you need to process the contents of the file in any way.


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

No comments:

Post a Comment