Forums

storage.py -> ValueError: Missing staticfiles

Hello,

My error is often reported one :

File "/home/achandol/.virtualenvs/env_garagesale/lib/python3.10/site-packages/django/contrib/staticfiles/storage.py", line 516, in stored_name raise 
ValueError(
    **ValueError: Missing staticfiles manifest entry for '/css/styles.css'**

I have searched for my issue in the forum and followed the steps on this page: https://help.pythonanywhere.com/pages/DjangoStaticFiles/

I have checked that I can access my css by going to https://achandol.pythonanywhere.com/static/css/styles.css

In the Web app setup, I have:

URL: /static/
Directory: /home/achandol/achandol.pythonanywhere.com/static

My settings.py has the following:

BASE_DIR = "/home/achandol/achandol.pythonanywhere.com"
STATIC_ROOT = os.path.join(BASE_DIR , 'static') 
STATIC_URL = '/static/'

I also see that everything is in lower case. I also tried clearing the browser history.

If someone can help me see what I am missing that would be great! I am sure I am missing something obvious.

Thank you!

To add further, I can access my admin site and do all the activities. But I cannot load my main pages. Thanks.

Debugging steps: 1. use of the "{% static %}" in html templates is causing the error: 2. changing this to full relative path makes it work

<link rel="stylesheet" href="{% static '/css/styles.css' %}" /> to <link rel="stylesheet" href="/static/css/styles.css" />

Question: Why am I not able to use {% static %} tag in my templates?

Error suggests that it cant find the styles.css

Looking at the template, it should be looking for the file /home/achandol/achandol.pythonanywhere.com/static/css/styles.css. Does this file exist?

Hi,

Thanks for your reply.

Yes, the file exists at the location you mentioned (it shows up in the tree). I can also access it at https://achandol.pythonanywhere.com/static/css/styles.css

My app actually works if I hardcode the link to css as -> href="/static/css/styles.css"

but it fails when I use the django variable -> href="{% static '/css/styles.css' %}"

For some reason, {% static %} is not getting imported in the html template. By bypassing that I could get everything else to work.

Thanks!

(env_garagesale) 17:03 ~/achandol.pythonanywhere.com (1014_changed_static_ref)$ pwd
/home/achandol/achandol.pythonanywhere.com
(env_garagesale) 17:03 ~/achandol.pythonanywhere.com (1014_changed_static_ref)$ tree static -L 2
static
├── admin
│   ├── css
│   ├── img
│   └── js
├── css    
│   ├── styles.css
│   ├── styles.css.gz
└── staticfiles.json

https://docs.djangoproject.com/en/5.1/howto/static-files/ has details about how to use static files in Django.