There is no css on my django admin page when viewed on apache server

I just finished to serve my pages online via apache. I see my webpage well, but when I try the admin, there is no css with it on the django admin page, just the html page. But my css webpage is displayed beautifully. Thanks!

my http.conf snippet:

WSGIPythonPath C:/Users/robin/web/etc/etc <Directory C:/Users/robin/web/etc/etc> <Files wsgi.py> Order deny,allow Allow from all </Files> </Directory> #Alias /robots.txt /path/to/mysite.com/static/robots.txt #Alias /favicon.ico /path/to/mysite.com/static/favicon.ico AliasMatch ^/([^/]*\.css) C:/Users/robin/web/etc/etc/static/styles/$1 #Alias /media/ /path/to/mysite.com/media/ Alias /static/ C:/Users/robin/web/etc/etc/static/ <Directory C:/Users/robin/web/etc/etc/static> Order deny,allow Allow from all </Directory> #<Directory /path/to/mysite.com/media> #Order deny,allow #Allow from all #</Directory> WSGIScriptAlias / C:/Users/robin/web/etc/etc/etc/wsgi.py <Directory C:/Users/robin/web/etc/etc/etc> <Files wsgi.py> Order allow,deny Allow from all </Files> </Directory> 

my settings snippet:

 STATIC_ROOT = 'C:/Users/robin/web/etc/static/' STATIC_URL = '/static/' 

I created another directory for statics and already directed django to a directory where you can find statics. I edited and added the settings fragment above, kindly check it out. And they ran the collectstatic command, and it created three directories - admin, css and images. And copied all the statics from the project to this directory, even admin css and images in the admin directory. And the server also displays my css project well. But not from admin css. What am I missing? Please guide me.

+4
source share
2 answers

Each application has its own static files (usually in a static directory, but not necessary, see settings.STATICFILES_FINDERS ). Django maintains these files in debug mode, but before deploying to a real server, you must collect all the static data from all applications, put them in one folder and configure the web server. You can do it manually or set settings.STATIC_ROOT in apache docroot and run collectstatic .

In total apache config:

 Alias /static/ C:/Users/robin/web/etc/etc/static/ 

settings.py:

 STATIC_ROOT = 'C:/Users/robin/web/etc/etc/static/' 

And run collectstatic:

 python manage.py collectstatic 
+3
source

Tell Django where to find the static files (if you haven't already).

First make sure that you have STATIC_ROOT and STATIC_URL set correctly in `settings.py ', and then on your live server just run the following command.

 python manage.py collectstatic 

This will collect all the static files necessary for the proper rendering of the administrator.

When the development server (runningerver) starts, static files are automatically detected using STATICFILES_FINDERS , but this is not the case in production, in reality STATICFILES_FINDERS does something else in production, it finds and collects files after `running python manage.py collectstatic," they then will be shipped in your Apache case.

+2
source

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


All Articles