Home > other >  Problem displaying admin in Django project
Problem displaying admin in Django project

Time:02-01

I ran the Django project on the C panel, but it looks like this in the admin section.

image

CodePudding user response:

You should collect static files

python manage.py collectstatic

and open the static files' URL by adding these rows to the project_name/urls.py file.

from django.conf             import settings
from django.conf.urls.static import static


urlpatterns = [
    ...
]

if settings.DEBUG:
    urlpatterns  = static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)

Maybe you should add root and URL paths in the project_name/setting.py file.

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, "static/")

CodePudding user response:

Django is not serving the static files, so you have to tell it where these files are located. Here in django documentation you can see how to do it https://docs.djangoproject.com/en/dev/howto/static-files/.

  •  Tags:  
  • Related