glasnt tries django-simple-deploy on heroku
I tried out the heroku deployment on a very smol sample project https://github.com/glasnt/django-simple-project
I got the deployment happening, but with some limitations:
The app deployed, but the admin looked funny (no static)
I looked up the code and you're using whitenoise, but not configuring it. It's been mentioned before.
I added this manually to my settings:
import os
if 'ON_HEROKU' in os.environ:
...
+ # from https://whitenoise.evans.io/en/stable/#quickstart-for-django-apps, install whitenoise after SecurityMiddleware
+ i = MIDDLEWARE.index("django.middleware.security.SecurityMiddleware")
+ MIDDLEWARE.insert(i + 1,"whitenoise.middleware.WhiteNoiseMiddleware")
Heroku will automatically run collectstatic as part of the push:
$ git commit -av
[main 1521f91] update heroku/whitenoise
1 file changed, 8 insertions(+), 1 deletion(-)
$ git push heroku main
remote: -----> $ python manage.py collectstatic --noinput
remote: 131 static files copied to '/tmp/build_47e52420/staticfiles'.
So once I ran this, the admin looked okay again:
The other issue I had is that because blank database, I had no django admin login.
I know I can fix this in heroku by running heroku run python manage.py createsuperuser and interactively re-create the admin user, which I did.
My simple app contained a Procfile already, so this file was not overridden (but it also already ran locally).
Still to do:
- [x] write introduction in discussion https://github.com/ehmatthes/django-simple-deploy/discussions/130#discussioncomment-3942286
- [x] try platform.sh #158, #159
- [x] try fly.io #156
- [x] Noting differences
- [ ] new platform shenanigans