2

I am running a Django project, and upon using python manage.py collectstatic in my terminal, my admin page stopped loading the css files and is in a raw html format. This is when I ran it using 127.0.0.1:8000. However, using localhost:8000, the css files load normally. What is the difference and why doesn't it work both ways ?

ChefMari
  • 41
  • 1
  • 2
  • 7
  • Did you start the server using `$ py manage.py runserver` for the Django built-in server or do you run a different one? – JSRB Nov 13 '19 at 16:20
  • Can you provide more specifics? localhost and 127.0.0.1 are the same – DBA108642 Nov 13 '19 at 16:21
  • @Phanti yea that's how I ran it. But for some reason it only works when I use localhost:8000 – ChefMari Nov 13 '19 at 16:24
  • @DemariCameron ok. Then just use the working one. For further information see https://stackoverflow.com/questions/20778771/what-is-the-difference-between-0-0-0-0-127-0-0-1-and-localhost – JSRB Nov 13 '19 at 16:25
  • @DBA108642 Yea that's why I'm confused lol. They're the same but my CSS files won't load using 127.0.0.1 , but they run when I use localhost:8000 – ChefMari Nov 13 '19 at 16:25
  • 1
    Despite what @DBA108642 has said, `localhost` and `127.0.0.1` are not necessarily the same. This may not be the source of your problem, but `localhost` will often resolve to `::1`, the IPv6 loopback address. This can be an issue if you have a service that is explicitly bound to the IPv4 loopback address. – larsks Nov 13 '19 at 16:44
  • 1
    Can you try `python manage.py runserver [::]:8000` and see if it works on both? – FlipperPA Nov 13 '19 at 16:54
  • @FlipperPA Yea the site works fine with both. It's just the admin page. Not sure if it is a big deal or a minor error in my code because it still functions. I was just curious because it's kinda weird to me that my css doesn't load for both – ChefMari Nov 13 '19 at 17:05

0 Answers0