python - Setup static file in Django from serving site in production mode -
i trying run static files same serving site in production mode. did.
in setting.py, have set,
debug = false allowed_hosts = ['12.10.100.11', 'localhost'] i included, 'django.contrib.staticfiles' in installed_apps
i set static root directory to,
static_root = os.path.join(os.path.dirname(base_dir), "static") i ran,
python manage.py collectstatic to copy static files local serving directory. (following: https://djangobook.com/serving-files-production/)
i point static url directory to,
static_url = ("/static/") i run,
python manage.py runserver 12.10.100.11:8000 however, on console inspect error shows:
**get http://12.10.100.11:8000/static/css/main.css 404 (not found)** on base.html looks this:
{% load static %} <link rel="stylesheet" href="{% static '/css/main.css' %}" type="text/css" /> i new django , need lots of advice, thanks
jef
you can't serve static files. django debug mode turned off isn't responsible that. ngnix better option chache mechanisms that. should check out heroku platform how deploy production ready django projects whitenoise example. github has lot of examples of opensource projects powered django can learn from
Comments
Post a Comment