Reputation: 2365
I am new to django
and currently I am making the tutorial. It goes well but every time at some point my admin site loses ist CSS styling and starts looking like this:
This problem is apparently not new, as I found few posts here (e.g., this one or this one) on the topic. Following the answers I made the next steps:
python manage.py collectstatic
Modifying settings.py
:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Adding the following lines to manage.py
:
import mimetypes
mimetypes.init()
mimetypes.types_map['.css'] = 'text/css'
Going sure that 'django.contrib.staticfiles'
in settings.py
is uncommented.
Nevertheless, nothing worked and my admin site still does not have CSS styling.
Note that in my case the problem is not consistent. Whenever I start a new project, the admin page is fine. The problem appears only after certain (and each time different) step throughout the tutorial. For example, last time it was after I modified the DATABASES
entry in settings.py
(though I went through this step smoothly one attempt before; changing the entry to its original value did not help to restore the admin page styling).
I am using django 1.9.6
with python 3.4.3
under Ubuntu 14.04
.
EDIT:
I am running server with #DEBUG = True
and ALLOWED_HOSTS = ['*']
Upvotes: 0
Views: 1315
Reputation: 1691
Django does not serve any static or media files when DEBUG = False
.
Changing the variable to True
and the static files for the admin site will appear. Otherwise, you will have to use a web server program to server the admin files as well as any other static/media files included in your project.
Upvotes: 3