Huzzah
Huzzah

Reputation: 45

How to make a pdf link in Django

I'm extremely new to Django and I was hoping someone could help me add a link to my website which allows someone to download a pdf file. The pdf file is located here:
static/files/offline_reg_form.pdf
and I have no idea what the URL should be in the urls.py file or the view in the views.py file. I have looked around but nothing is working as I want it too.

Any help would be great, thanks!

Upvotes: 0

Views: 5717

Answers (2)

tw0shoes
tw0shoes

Reputation: 174

For you specifically:

{% load static %}
<a href="{% static "files/offline_reg_form.pdf" %}">my pdf</a>

Upvotes: 7

Art
Art

Reputation: 2335

This will answer your questions.

https://docs.djangoproject.com/en/1.10/howto/static-files/

If it still confuses you, {% load static %} <img src="{% static "my_app/example.jpg" %}" alt="My image"/> is an example of what should be in your template.

Upvotes: 3

Related Questions