0

I've read this: Django - Static file not found

but I'm still confused since one of my project's app's static files are being served. I think the problem lies in a django-weasyprint setting:

settings.py

>>> settings.BASE_DIR
'/Users/blakepowell/django_/direct2'
>>> settings.STATIC_ROOT
'/static/'
>>> settings.BASE_DIR
'/Users/blakepowell/django_/direct2'
>>> settings.DJANGO_ROOT
'/Users/blakepowell/django_/direct2'
>>> settings.STATICFILES_DIRS
['/Users/blakepowell/django_/direct2/flights/static/', '/Users/blakepowell/django_/direct2/pdf_output/static/']

pdf_output/views.py per django-weasyprint

class PrintView(WeasyTemplateResponseMixin, PDFView):
    # None
    pdf_stylesheets = [
    settings.STATIC_ROOT + 'pdf_output/static/pdf_output/css/pdf_output.css',
    ]

error

[Errno 2] No such file or directory: '/static/pdf_output/static/pdf_output/css/pdf_output.css'

Any Ideas?

user2498975
  • 129
  • 16

1 Answers1

0

In your settings.py you have

STATICFILES_DIRS = [
    '/Users/blakepowell/django_/direct2/flights/static/',
    '/Users/blakepowell/django_/direct2/pdf_output/static/'
]

I think? Now you can access the files in these directorys diretly via /static/ :

class PrintView(WeasyTemplateResponseMixin, PDFView):
    # None
    pdf_stylesheets = [
        '/static/pdf_output/css/pdf_output.css',
    ]

if your css file is under /Users/blakepowell/django_/direct2/pdf_output/static/pdf_output/css/pdf_output.css

or via

class PrintView(WeasyTemplateResponseMixin, PDFView):
    # None
    pdf_stylesheets = [
        '/static/css/pdf_output.css',
    ]

if your css file is under /Users/blakepowell/django_/direct2/pdf_output/static/css/pdf_output.css

I can not see where your css file is located on your machine. Why are you using two 'static' folders?

dome12b
  • 583
  • 11
  • 32