[Python] Static files won't load when using Vercel

Discussão em 'Python' iniciado por Stack, Fevereiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    When I host my project locally, everything works. My stylesheet loads without a problem, however when I deploy it to Vercel neither the admin static files nor my own load. Here is my settings.py:

    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles_build', 'static')
    MEDIA_URLS ='/media/'
    MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


    and my vercel.json:

    {
    "builds": [{
    "src": "social/wsgi.py",
    "use": "@vercel/python",
    "config": { "maxLambdaSize": "15mb", "runtime": "python3.9" }
    },
    {
    "src": "build_files.sh",
    "use": "@vercel/static-build",
    "config": { "distDir": "staticfiles_build" }
    }],
    "routes": [
    {
    "src": "/static/(.*)",
    "dest": "/static/$1"
    },
    {
    "src": "/(.*)",
    "dest": "social/wsgi.py"
    }
    ]
    }


    So far I have run the collect static command and I have tried changing the root and the url, but I am very lost and do not fully understand why it will not work.

    Continue reading...

Compartilhe esta Página