I\'ve been struggling with this for so long that I\'m bordering depression.
I have a model called \"Song\" that looks like this.
from django.db import mo
You should add MEDIA_ROOT and MEDIA_URL configuration. It will be easy to handle things. Here is the solution to your problem.
In settings.py:
MEDIA_ROOT=os.path.join(BASE_DIR,"songdir")
MEDIA_URL='/media/'
Also in settings.py add 'django.template.context_processors.media', in the TEMPLATES option's context_processors.
In project/urls.py:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Then you can simply use:
{{link.url}}
instead of hardcoding it in your template file.