2

Today I deployed my project on a hosting server and since I have DEBUG = False I have an internal server error too. The full report is:

/storage.py", line 280, in stored_name
    cache_name = self.clean_name(self.hashed_name(name))
    File "/home/ttipprotest/lib/python3.4/django/contrib/staticfiles
/storage.py", line 94, in hashed_name
    (clean_name, self))
    ValueError: The file 'css/styles.css' could not be found with 
<django.contrib.staticfiles.storage.ManifestStaticFilesStorage object at 
0x7f2787c23ef0>.

Everything was working fine in developement, but now I am trying to solve this problem during the whole day. Sorry for displaying the error message that bad.

EDIT:

in prod settings:

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

STATIC_URL = '/static/'
STATIC_ROOT = "/home/ttipprotest/webapps/ttipprotest_static/"
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static', 'our_static'),
)

MEDIA_URL = '/media/'
MEDIA_ROOT = "/home/ttipprotest/webapps/ttipprotest_media/"

Project structure:

src
-ttipprotest
--manage.py
--settings
---base.py
---prod.py
-app 1
-...
-app n
-static
--our static
---css
---js
---fonts
-templates

SECOND EDIT:

The problem appears every time when it comes to rendering a template it seems. Here is the index.html. I guess it is the source of this behavior since I figured out that other applications without this index.html are working fine.

{% load staticfiles %}
{% load crispy_forms_tags %}
noob-py
  • 63
  • 8
  • where you deployed it? If it some VPS you should read about deploing with UWSGI or Gunicorn and web server like NGINX – Ivan Semochkin Jul 11 '16 at 19:42
  • Have you had a read of https://docs.djangoproject.com/en/1.9/howto/static-files/deployment/? The difference between development and production environments is that you need to tell Django where to find the static files, where to copy them to (if running with the usual `collectstatic` arrangement), and at what URL the server will be serving them. – nimasmi Jul 11 '16 at 19:53
  • It is shared server hosting via apache2. I set the static like it was recommended by the hoster – noob-py Jul 11 '16 at 19:54
  • @nimasmi. Yes I did. Maybe I have skiped something. I'll make an edit of my prod settings – noob-py Jul 11 '16 at 19:56
  • If you're still stuck, then I think the question could be improved by adding some relevant bits from your production settings file, telling us what your project's directory structure is, and stripping the error traceback to just the last three lines. – nimasmi Jul 11 '16 at 20:00

1 Answers1

3

Found the mistake while I was making the edit.

In index.html:

{% load staticfiles %}

was perfectly working fine with DEBUG = True. At least it was rendering and showing the template, but in the logfile where shown errors. index.html is the template mostly every other template extends on.

After I changed index.html to:

{% load static %}

it is working fine with DEBUG = False

noob-py
  • 63
  • 8