DEV Community

Cover image for How to host Django Project on Vercel
Odipo Otieno (KwargDevs)
Odipo Otieno (KwargDevs)

Posted on

How to host Django Project on Vercel

  • In settings.py, set ALLOWED_HOSTS=[".vercel.app"]
  • add a file in same directory as manage.py called vercel.json and in the file write the code:
    {
    "builds": [{
        "src" : "django_project/wsgi.py",
        "use" : "@vercel/python",
        "config" : {"maxLambdaSize": "15mb", "runtime" : "python3.9"}
    }],
    "routes": [
        {
            "src" : "/(.*)",
            "dest": "django_project/wsgi.py"
        }
    ]
    }

NOTE: * replace django_project in the code with the name of your project * If you use the name of app instead, it will not work.

  • Navigate to your project folder and open file called wsgi.py, add line


    app = application
    at the bottom of the file.
  • run command pip freeze > requirements.txt Make sure requirements.txt file is created in the same directory as the manage.py.

  • run git add, git commit, and git push commands to push the code to github.

  • create a vercel account and import your repository on vercel from github and that's just it.

Follow For More!!

Top comments (0)