Reputation: 432
I've a website running on Django, Heroku. I need to add few static JavaScript files for a third-party plugin.
My newly added files are available at domain.com/static/filename.js
.
I need them to be available at domain.com/filename.js
.
How to make ONLY the newly added Javascript files available at domain.com/filename.js
?
If the info is not sufficient please ask which code is needed in the comments.
Upvotes: 1
Views: 219
Reputation: 2513
If there are only a couple of these files, I guess you could do the following:
Upvotes: 0
Reputation: 136
My first choice in this situation would be to fix whatever is stopping you from putting it into /static/
. I can't imagine any half-decent third-party plugin would demand that the files be in the root; there must be some way to configure it to work from a subdirectory. If there isn't, I'd fork the project and add the option, then try to get them to merge it back. I realise you've probably already explored this option, but can you give us some more details about the plugin you're trying to use, and the reason it needs to go into the root? This really would be the best solution.
If you really must have the file in the root, and want to keep it as part of your django project, I'd try symlinking the files into the public root. This would mean it would be available in both locations; I can't see why that would be a problem, but you do specify "ONLY" in the root and I'm sure you have your reasons; in that case, perhaps you could configure your web server to redirect from /static/filename.js
to /filename.js
?
Lastly, you technically could change the settings STATIC_URL
and STATIC_ROOT
to point at the root directory, but that sounds like a pretty terrible idea to me. If you've got this far and still need to do it, it would be far better to take the file out of your django project altogether and just manually place it in your web root.
Upvotes: 3