Bootstrap does not be set to my Django app.In google console,Failed to load resource: the server responded with a status of 404 (Not Found) bootflat.min.css error happens.I wrote in settings.py
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG =True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
STATICFILES_DIRS = [os.path.join(BASE_DIR,'bootflat.github.io'), ]
in PythonServer_nginx.conf
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name MyServerIPAdress; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location /static {
alias /home/ubuntu/PythonServer/PythonServer/accounts/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/ubuntu/PythonServer/uwsgi_params; # the uwsgi_params file you installed
}
}
I do not know why Bootstrap does not be set to my Django app.I run command python manage.py collectstatic but no error happens.How should I fix this?What should I write it?
I assume the project works fine in local, this problem occurs only when you use nginx. If that is the case probably the path you mentioned in the nginx config for location /static is wrong, try getting the absolute path to the static folder from the server and see.
I have no way to test my answer for obvious reason, but your STATICFILES_DIRS
and STATIC_ROOT
don't match. If you change your STATICFILES_DIRS
to [os.path.join(BASE_DIR,"/static/"),'https://bootflat.github.io']
, it might work. I suggested so because it doesn't make sense to me to os.path.join
a local path with a public URL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With