Django cms does not see static folder

I am very new to Django .... and after several hours of struggle I managed to install django cms in virtual env. Creating some template and adding some page to my cms. Now I'm trying to add some css .... and I created a static folder with an internal css folder and my style.css. But it seems that my cms does not see the static folder, and I have a 404 error if I try to go: 8000 / static / css / style.css In my .py setting I have this

STATIC_ROOT = os.path.join(PROJECT_PATH, "static") STATIC_URL = "/static/" 

not sure what helps pls not

+2
source share
3 answers

You must enable URL mapping for the static resource by adding the following lines to urls.py:

 # redirects to static media files (css, javascript, images, etc.) (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': 'static/'}), 

UPDATE 1: Check if another user has access to your project directory. chmod -R 755 may be useful.


UPDATE 2: Make sure the following lines are in settings.py

 # List of finder classes that know how to find static files in various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) 

UPDATE 3: I checked the settings.py my project called webui :

 STATIC_ROOT = '' STATIC_URL = '/static/' STATICFILES_DIRS = ( 'webui/static', ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) 
+4
source

I am trying to integrate django-cms into an existing Digital Ocean Django installation and I am facing the same problems. Although I was able to serve static files for everything else, for some reason my django-cms files kept returning 404. I checked settings.py and permissions, but I had no luck.

On Ubuntu 14.04, run Nginx and Gunicion

I edited

 sudo nano /etc/nginx/sites-enabled/django 

And I added the following code block

 location /static/cms { alias /usr/local/lib/python2.7/dist-packages/cms/static/cms/; } 

Then I restarted Nginx and Gunicorn

 sudo service nginx restart && sudo service gunicorn restart 

and I was able to see all the missing static files

+2
source

I had the same problem. Which helped me finally move the static files to the "static" folder of the user application.

+1
source

Source: https://habr.com/ru/post/904012/


All Articles