Search code examples
djangodjango-templatesdjango-staticfiles

Django admin site fails to load using static CSS


I have Django project for which the built-in admin client has stopped working. It looks like Python is failing to handle a list object when it is expecting a string(?) while loading a CSS file using Django's "static" methods. I've gone over my settings.py and admin.py and checked all "static" config settings against the Django documentation. When I run different Django projects, the admin site works fine.

Here are the errors and settings from the project. I'm running Django 4.1.5 and Python 3.10.6 on the Django dev web server. Any pointers and advice are greatly appreciated.

web page returns:

AttributeError at /admin/login/
'list' object has no attribute 'rsplit'
Request Method: GET
Request URL:    http://localhost:8000/admin/login/?next=/admin/
Django Version: 4.1.5
Exception Type: AttributeError
Exception Value:    
'list' object has no attribute 'rsplit'
Exception Location: /usr/local/lib/python3.10/dist-packages/django/utils/module_loading.py, line 25, in import_string
Raised during:  django.contrib.admin.sites.login
Python Executable:  /usr/bin/python
Python Version: 3.10.6
Python Path:    
['/home/ed/PycharmProjects/wikidataDiscovery',
 '/usr/lib/python310.zip',
 '/usr/lib/python3.10',
 '/usr/lib/python3.10/lib-dynload',
 '/home/ed/.local/lib/python3.10/site-packages',
 '/usr/local/lib/python3.10/dist-packages',
 '/usr/lib/python3/dist-packages']
Server time:    Sun, 26 Mar 2023 05:44:51 -0700

and

pick of template error

Here's all "static" info in settings.py:

STATIC_URL = 'static/'

# STATIC_ROOT = ''

STATICFILES_STORAGE = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

Solution

  • STATICFILES_STORAGE is expected as a scalar value

    e.g.

    STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'

    what you specified are static file finders

    STATICFILES_FINDERS= [
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    ]