Simple to say but difficult in django?

44 views
Skip to first unread message

Luca Brandi

unread,
Apr 9, 2016, 12:56:54 PM4/9/16
to Django users
Hi,
I need to make something very simple but it seems all exmplesI found on the web, do not work, so I am sure this group will find the right solution (please consider I am a newbie so please be specific and detailed in your reply):
I just need to store a pdf file in my sytic files and have a link on a page which opens it.
Best solution I found is not working...:
view.py:
@login_required
def pricelist (request):
    template='pricelist.pdf'
    return render (request, template ,{})
 
url.py:
url(r'^pricelist/$', 'aero.views.pricelist', name='pricelist'),

url link in the page: <a href="{{ MEDIA_URL }}/pdf/pricelistAR.pdf">Download</a>


anyone can help? thanks very much

Vijay Khemlani

unread,
Apr 9, 2016, 1:13:12 PM4/9/16
to django...@googlegroups.com
Your question seems to be incomplete

considering you are using a login_required decorator then you also want to limit access to the file

If you put it in your static directory then it will be public if anyone knows the URL to the file

--
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a0d7a435-1a46-4cee-9d04-0ade09363ae7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luca Brandi

unread,
Apr 10, 2016, 3:20:13 AM4/10/16
to Django users
You are right: these files should be downloadable only to authenticated users.. If not in the static folder, where should I store them and how to make them downloadable? thanks
Reply all
Reply to author
Forward
0 new messages