0

I'm trying to deploy a Django project using a VPS - it uses Apache and mod_wsgi. (It works fine locally). My homepage is displayed, but no static file is found, leading to a goofy display.

I have configured my static files this way :

settings.py :

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

urls.py

urlpatterns = [
    path('', home, name='home'),
    path('output/<str:region>/<str:summoner_name>', output, name='output')
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

call in template :

home.html

After that I ran collectstatic, which created a "static" folder on root, as expected. I have checked via SSH and FTP, it is there : see here, with the correct permissions. The URL to access it should then be : mywebsiteurl/static.

But I get this 404 error, even though my explorer seems to look for the correct adress :

errors

I simply don't understand how can I get a 404 when requesting a file that seems to exist.

Ivan Starostin
  • 8,798
  • 5
  • 21
  • 39
Axel
  • 1
  • 1
  • 1
    Please don't post [text as pictures](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors). Template code is a text same as error messages. Django [is not supposed to](https://docs.djangoproject.com/en/4.1/howto/static-files/deployment/#serving-static-files-in-production) serve static/media files on prod, with DEBUG=False. [Configure your Apache](https://stackoverflow.com/questions/5682809/django-static-file-hosting-an-apache) to handle those files. Show apache config if you have configured one. – Ivan Starostin Jan 24 '23 at 18:45

0 Answers0