Hi! I just recently got my web app up on PythonAnywhere, and during my testing, I noticed this on my Admin Dashboard:
This does not happen locally. What might be the cause? How to fix? Thanks!
Hi! I just recently got my web app up on PythonAnywhere, and during my testing, I noticed this on my Admin Dashboard:
This does not happen locally. What might be the cause? How to fix? Thanks!
Take a look at https://help.pythonanywhere.com/pages/DjangoStaticFiles
Hi, sorry for the late reply.
Yeah, those steps were already done. At first the css wasn’t showing at all, then found out that’s what I needed to do first…
Do you have the same version of Django on your local machine?
Yes I do (v3.2).
And you display it in the same browser?
Yeah, (Firefox).
Are there any errors in the browser's web developer console? On Firefox, you can access it from the hamburger menu, then "Web developer", then "Web console".
Hi.
I looked in the console, and this is what I see:
I have my suspicions.
Make sure that static file mappings on the Web page are set correctly and correspond to the paths you have in your project.
It looks like they are set correctly on the dashboard, yes... Not sure how to set it for my admin page besides in my settings file, which has been done long ago.
Try to get that files directly from the url and see if you get what you expect.
Result...
I also get this message on that page:
The current path, static/admin/css/nav_sidebar.css, matched the last one.
I think the message is meaningful -- you've set /static/
and /static/admin
, so the second one is caught by the first and your mappings don't work correctly.
Hmm. What do I change and where?
If you have multiple static files locations, check STATICFILES_DIRS
setting: https://docs.djangoproject.com/en/3.2/ref/settings/#std:setting-STATICFILES_DIRS
and keep only one /static/
mapping in the Web page instead of multiple colliding ones.
Ultimately, if you don't want to have two different static file locations, it would probably be best to move your admin css to the static folder. Move all your CSS to static/admin/css/ Then do the same for your JS, images, etc static/admin/js static/admin/images
That would be the easiest way imo.