I'm trying to update Wagtail from version 2.8 to the latest 2.15. Also, I had to update from Django 3.0 to 3.2. However, I noticed that when I use STATICFILES_DIRS, the style of the Wagtail admin (2.15) gets distorted as if it's using the files from the old version (2.8).
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
...
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
STATICFILES_DIRS = [os.path.join(PROJECT_DIR, 'static'),]
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
Conversely, when I delete the STATICFILES_DIRS, the style on the Wagtail admin gets fixed, but the all the style on my project its gone.
I already checked and it's not the cache. I tried that several times, different browsers, etc.
CodePudding user response:
Try changing:
STATICFILES_DIRS = [os.path.join(PROJECT_DIR, 'static'),]
to
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'),]
CodePudding user response:
Your STATICFILES_FINDERS setting tells Django that it should look for static files in the following places:
FileSystemFindertells it to look in whichever locations are listed in STATICFILES_DIRS;AppDirectoriesFindertells it to look in thestaticfolder of each registered app in INSTALLED_APPS.
In normal circumstances, STATICFILES_DIRS should not make a difference to Wagtail's own static files. This is because Wagtail's static files are stored within the apps that make up the Wagtail package, and will be pulled in by AppDirectoriesFinder - FileSystemFinder (and STATICFILES_DIRS) do not come into play.
The fact that you're seeing a difference suggests to me that you've previously customised Wagtail's JS / CSS by placing static files within your project's 'static' folder, in a location such as myproject/static/wagtailadmin/css/, to override the built-in files. These customisations would presumably have been made against Wagtail 2.8 and will not behave correctly against Wagtail 2.15. The solution is to remove these custom files from your project.
