I need to serve a particular static asset only to users logged into my Django site. I'm serving static assets through Apache. For various reasons I’m not interested in standing up a full CMS — I just need to make sure non-qualified site visitors cannot download this particular file.
This is really low traffic site so failing all else I can hardcode a urlpattern & serve it as a template.
But there's gotta be a smarter way to do this, right?
EDIT:
Here’s where I settled for now:
# views.py
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
@login_required
def secretfile(request):
return render(request, 'secretfile.xls')
# urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'secretfile.xls', views.secretfile),
]