I have a problem with generating a PDF file - django does not provide for wkhtmltopdf static files if the path looks like this:
<link rel="stylesheet" type="text/css" href="{% static 'flot/fms.css' %}">
but if I give a direct path it works:
<link rel="stylesheet" type="text/css" href="http://localhost:8000/static/flot/fms.css">
The problem with static files is only when generating PDF from web, from console files generate correctly.
You need to properly configure STATIC_ROOT
and STATIC_URL
for production. Depending on STATICFILES_DIRS
and what STATICFILES_FINDERS
you have configured, your static sources will be located together with your application's sources, while the STATIC_ROOT
must be outside the path of your sources since this data is transient by nature.
This means that you must rely on running $ python manage.py collectstatic
in production. Paths matching STATIC_URL
should be handled by your web server, with the root configured to match STATIC_ROOT
from where the files will be served.
You can review the django.contrib.staticfiles
app guide and the guide on deploying static files in production from the documentation for more nitty-gritty details.
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