Maybe a view with something like
def priv_file(request):
if request.user.is_anonymous:
return render_to_response("goaway.html")
else:
path = "Path to file"
data = open(path)
type = "whatever"
return HttpResonse(data, content_type=type)
A T.Khan wrote:
Hello everyone,
I am relatively new on Django, in fact I got to know about it through
Openstack Dashboard which works using Django. anyway I got a question
and I been looking for it for a month now without getting any good
results, I finally decided to ask some of the experts here. If I am
violating any rules by posting it or if someone has already answered
it, please tell me. I hope this community is friendly enough to
oversee this.
I have already a Django setup running (you guessed it devstack), and
it works fine. I have done plenty of editing already. But now I want
to add a download button on a page, and by clicking to it, a file
should be downloaded. Seems simple enough, but right now what I have
done is adding
<a href="{{ MEDIA_URL }}/test.file" %}" class="btn-download">{% trans
"Downloadl" %}</a>
in one of the files. This works perfectly ... however this link works
but It is simple html encoding, and it works even when I am not logged
in, bypassing the entire purpose of file security. I have tried to
embed the code in some py files but then it gives me debug error.
So I will be really grateful if someone can guide me what to do here.
All I want is to add a download button/link on a page and a file to be
downloaded. I tried staticfiles and media_url methods, not the result
I want. Please help me that where I need to make changes in which
configuration files and how will it work.
Thanks in Advance
Best of Regards,
AT
--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
Mike Doroshenko, Junior Sys Admin
TecKnoQuest Inc.
mi...@tecknoquest.com
www.tecknoquest.com
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.