Reputation: 205
I have developed a website using the latest version of Django, finished all the offline testing, and deployed it to Google App engine. Previously, images and scripts for my website were located in a folder titled ‘scripts’, and running locally I had no problems.
Now that my website is deployed however, no images / scripts / static files are successfully loading, and I cannot figure out an appropriate fix.
I have successfully created a bucket with google cloud, but I can’t seem to create a functioning path to that bucket. I am unsure whether a html address is a valid parameter for the path location in Settings.py, and regardless replacing the simple HTML address of my google cloud bucket for my STATIC_URL parameter has not fixed the problem.
Has anybody else run into this problem, and does anyone know the best configuration for the static_url parameter in Settings.py? Or a simpler way to set up your static files? Thanks in advance!
Upvotes: 1
Views: 374
Reputation: 4640
You need to specify a static directory on your app.yaml file, for example:
handlers:
- url: /scripts
static_dir: scripts/
In this github repo you can find a full example of Django and app engine
keep in mind that the main idea of the static directories is serve content to the front-end, all resources in that path will be publicly accessible
If you need access to another files within your app engine service you need to get the relative directory of your mail script, try to use this code
import os
dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, 'relative/path/to/file/you/want')
Upvotes: 2