Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does my Django admin site not have styles / CSS loading?

Tags:

css

django

admin

I made a Django admin site using Django development version but it isn't being styled:

alt text

like image 537
zjm1126 Avatar asked Dec 12 '10 04:12

zjm1126


People also ask

Why Django admin is not working?

'django-admin' is not recognized as an internal or external command, operable program or batch file. To fix this, first close the terminal window and relaunch it with administrator privileges. Once you launch the elevated terminal window change directory to where you wish to start your Django project.

How can we load css file in our Django templates?

The static folder should be created in your project folder, that's where you can create in static folder a folder called css, and then in the css folder add the css files.


2 Answers

After setting up your STATIC_ROOT and STATIC_URL, you may have to run

python manage.py collectstatic 
like image 122
David Mann Avatar answered Sep 18 '22 07:09

David Mann


ADMIN_MEDIA_PREFIX is deprecated now, use STATIC_URL instead. Setting STATIC_URL = '/static/' in settings.py should do the job. Try:

import os.path   import sys  PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) 

and then:

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static') STATIC_URL = '/static/' 

Works on Django 1.4 pre-alpha SVN-16920.

like image 29
Shamar Avatar answered Sep 21 '22 07:09

Shamar