I think the question is wrongly stated.
Django is capable to serve static files, but by default it is disabled on production, and it is clearly stated it is just for development purposes.
So, everybody agrees that using django to serve static files is a bad idea :-)
However, as you put it, you do not want to use django for serving static files, you want to use django to implement some kind of "security" on file download.
As I understand it, the file is not static at all; on the contrary, it is definitely dynamic!
I think you have two possible options:
- Use django to parse the URL, and then redirect to another server (e.g. nginx) for serving the file. This is for sure the fastest way, but it has the obvious disadvantage of giving away the "real" address of the file.
- Use django to parse the URL, and then serving the PDF directly. It completely implements your original requirement (one-time URLs) but scaling up on performance could be quite difficult.
I think the second point needs some more details.
Serving a file requires some time; using django to serve it is not less efficient than any other method (most of the time is spent in waiting for the I/O), but it may consume a thread, or a process on your server.
If you plan to have many connections at the same time, this approach may have serious drawbacks; on the other hand, if you need to serve small files to a limited audience, then it may be completely OK.