Unusual dark mode option in Django Admin

352 Views Asked by At

I added the following code in my setting.py:

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = 'static/'
STATICFILES_DIRS = [
    BASE_DIR / 'static',
    os.path.join(BASE_DIR, 'static')
]

The app is able to find my .css file. However, it seems like the Django admin is not able to find its css files. And all of a sudden the following options show up in Django Admin.

Django Admin login

Django Admin after login

When I comment out the code, these dark mode options disappears and Django admin works properly. Is this a bug in the Django 4.2? Or did I setup my static directory incorrectly?

1

There are 1 best solutions below

0
Nurlan Pirjanov On

It looks like there is a bug in the Django framework. Try creating a new virtual environment or uninstalling Django and reinstalling it.

settings.py

if DEBUG:
    STATICFILES_DIRS = [
        BASE_DIR / 'static'
    ]
else:
    STATIC_ROOT = BASE_DIR / 'static'

STATIC_URL = 'static/'