#Trying to publish a simple django app

19 messages · Page 1 of 1 (latest)

sudden compass
#

Hello, I have a basic wsgi django application. I've configured env variables and followed the instructions here (https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/#https) to prep for production.

I'm using Netlify as my hosting provider, and in build settings I'm not sure what to put as the build command or the publish directory. I currently have the following settings:
base directory: /
package directory: Not set
build command: pip install -r requirements.txt
publish directory: python3 manage.py runserver 0.0.0.0:80

But when I deploy my site, I get the following build error:
12:30:07 PM: $ pip install -r requirements.txt
12:30:08 PM: ​
12:30:08 PM: (build.command completed in 949ms)
12:30:08 PM: ​
12:30:10 PM: Failed during stage "building site": Build script returned non-zero exit code: 2
12:30:10 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:30:10 PM: Failing build: Failed to build site

I think it's because my requirements.txt is empty. Honestly I only created it because I saw somewhere that I needed it. I created it using a command that compiles the packages that I need, but since nothing was produced does that mean my app doesn't need to install any packages?

Side note:
I recently switched to a windows computer and I'm running into issues getting python stuff installed locally, like venv for example. Really struggling here, I am starting to feel frustrated because I'm tripping at the finish line. Thanks for your help, I really do appreciate it a ton. 🙂

violet trellis
#

Netlify doesn't provide support for hosting django sites.

sudden compass
#

LOL well I guess that would do it

#

what would you suggest? Is there any free option out there?

#

Can I use my sqlite db in production without any issues?

violet trellis
#

Expect to pay for something at some point for anything that you would consider a serious project.
Some options to look at:

  • Pythonanywhere
  • Vercel
  • Fly.io
  • render

I have yet to use any of these myself (yet). I generally default to a linux server running dokku myself, but that depend on your linux/sys admin experience.
Generally you will pay less in $ for hosting just on a VPS, but you will make up for in paying it in time.
Other paid PaaS services cost more but are simpler to deploy to.

sudden compass
#

thanks for the advice

violet trellis
#

In terms of sqlite, while you can use it in a production context, but as it is a single file you need to be careful about what your chosen hosting provider does with filesystems and machines.
A classic example of this is Heroku who have dynos which can reboot at anytime meaning you lose anything saved to the filesystem. This is intentional so you can easily scale horizontally and vertically between machines. As such postgresql is normall recommended in this case.

sudden compass
#

is it hard to convert my project to use postgresql?

violet trellis
#

It shouldn't be too hard, but again it really depends on your experience with these kind of tasks

sudden compass
#

I went to vercel to host and for my build settings it has these as the default:
build command: 'npm run vercel-build' or 'npm run build'
output directory: 'public' or '.'
install command: 'yarn install', 'pnpm install', or 'bun install'

Do these look right? What kind of changes will I need to make for my app?

#

I don't think I'm using npm in this project...

violet trellis
#

Start by looking at this repo for how to configure your repo: https://github.com/vercel/examples/tree/main/python/django
This should help as well:
https://vercel.com/templates/python/django-hello-world

Vercel is like Netlfiy in how it hosts stuff in general, so it's very Javascript geared.

GitHub

Enjoy our curated collection of examples and solutions. Use these patterns to build your own robust and scalable applications. - vercel/examples

Use Django 4 on Vercel with Serverless Functions using the Python Runtime.

sudden compass
#

I followed the instructions above, but now I am getting an error: "This serverless function has creshed."

#

500: INTERNAL_SERVER_ERROR
Code: FUNCTION_INVOCATION_FAILED
ID: sfo1:sfo1::52dpv-1695498708969-43c8075ad3aa

#

ok I went and took a look at my logs

#

this is my specific error:

#

[ERROR] Runtime.ImportModuleError: Unable to import module 'vc__handler__python': No module named 'django'
Traceback (most recent call last):

violet trellis
#

At this point I cannot help specifically with vercel. You need to make sure you have their specific files and configuration setup to run django correctly.