I am new to python & django. I have learnt basic of both and made a simple project called PythonDjangoDemo. I have visited admin urls during development. But I am unable to load css for admin url in python-django project. At first lets look at project structure. I have -
PythonDjangoDemo
|--- PythonDjangoDemo
| |--- __init__.py
| |--- settings.py
| |--- urls.py
| |--- wsgi.py
|--- static_cdn
| |--- admin
| | |--- css
| | | |---base.css
| | | |---login.css
| | |--- fonts
| | |--- img
| | |--- js
|--- media_cdn
|--- templates
|--- manage.py
|--- db.sqlite3
Let's have a look at settings.py
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
... ... ...
STATIC_URL = '/static/'
MEDIA_URL = "/media/"
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_cdn")
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "media_cdn")
I have put all my css for admin urls at "static_cdn/admin/css". When I try to access "127.0.0.1:800/admin" I do not get any error(s). Here is the console output -
[30/Apr/2017 16:04:58] "GET /admin/ HTTP/1.1" 302 0
[30/Apr/2017 16:04:59] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 1650
[30/Apr/2017 16:04:59] "GET /static/admin/css/base.css HTTP/1.1" 200 16066
[30/Apr/2017 16:04:59] "GET /static/admin/css/login.css HTTP/1.1" 200 1203
Not Found: /favicon.ico
[30/Apr/2017 16:04:59] "GET /favicon.ico HTTP/1.1" 404 2329
Could you please explain
- What is going on wrong compared to the console response (that is no error)?
- And what is the meaning of STATIC_URL and STATIC_ROOT?