Tuesday, May 31, 2011

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

> I am a bit confused about how to set the MEDIA_URL variable here.
> Currently, I am testing the web using Django embedded webserver and
> doesn't have a proper url yet. Should my MEDIA_URL be something
> like... http://my_machine_name:8000/media/


yes, but so in your template you do:

> ### in the template ####


> <a href="{{ MEDIA_URL }}{{ django_file.url }}>download</a>


Your:
> <a href="file:///{{ django_file.url }}>download</a>
file:/// will only work on you machine, since file:/// is pointing to a local file

--
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