Django admin site does not show CSS style

My admin site, Django (it is completely default, not configured) does not show the expected CSS.

It looks like this:

enter image description here

And I can log in:

enter image description here

But it should look like this:

enter image description here

How to fix it?

Additional information that may help:

I am running an instance of Amazon EC2 on port 80 and connecting to it using a real URL. I installed it using this tutorial: http://www.nickpolet.com/blog/deploying-django-on-aws/1/

Following this tutorial, I put this code in a file called /etc/apache2/sites-enabled/mysite.conf . I don’t understand what this code is doing, so I think it might be due to the problem.

/etc/apache2/sites-enabled/mysite.conf:

 WSGIScriptAlias / /home/ubuntu/cs462/mysite/mysite/wsgi.py WSGIPythonPath /home/ubuntu/cs462/mysite <Directory /home/ubuntu/cs462/mysite/mysite> <Files wsgi.py> Order deny,allow Require all granted </Files> </Directory> Alias /media/ /home/ubuntu/cs462/mysite/media/ Alias /static/ /home/ubuntu/cs462/mysite/static/ <Directory /home/ubuntu/cs462/mysite/static> Require all granted </Directory> <Directory /home/ubuntu/cs462/mysite/media> Require all granted </Directory> 

Directory structure:

 /home/ubuntu/cs462/ mysite/ manage.py db.sqlite3 mysite/ __init__.py __init__.pyc settings.py settings.pyc urls.py wsgi.py homepage/ admin.py admin.pyc __init__.py __init__.pyc migrations models.py models.pyc tests.py views.py 

The last part of settings.py:

 # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.7/howto/static-files/ STATIC_URL = '/static/' 
+5
source share
1 answer

Configuring your Apache requires all static content (CSS, JS, images, etc.) to be in the mysite / static directory. First you need to pick up your static content from applications in the mysite / static directory:

 cd /home/ubuntu/cs462/mysite python manage.py collectstatic 

Update. If you did not specify a location for static content, you should add the following lines to settings.py :

 STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') 
+17
source

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


All Articles