[Answer]-Django Admin site – display issue

1👍

Thanks theguywhoanswered for the answer(which I presume he has deleted). It resolved my issue. The cause was two fold and needed the following modifications.

Changes required

In settings.py add

PROJECT_ROOT = Path(__file__).ancestor(2)
STATIC_ROOT= os.path.join(PROJECT_ROOT,'static_media/')
STATIC_URL = '/static/'

In urls.py add

urlpatterns += patterns('',
url(r'static/(.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
)

Also create a admin.py file under books directory whose contents should be :

from django.contrib import admin
from books.models import Publisher, Author, Book

admin.site.register(Publisher)
admin.site.register(Author)
admin.site.register(Book)

also run python manage.py collectstatic from mysite directory

After doing all this restart the server. Your page should look like below enter image description here

0👍

Make sure that django.contrib.staticfiles in settings.py is uncommented, this it was my trouble.

Leave a comment