Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

glasnt tries django-simple-deploy on heroku #152

Closed
4 of 5 tasks
glasnt opened this issue Oct 22, 2022 · 3 comments
Closed
4 of 5 tasks

glasnt tries django-simple-deploy on heroku #152

glasnt opened this issue Oct 22, 2022 · 3 comments
Labels
heroku stability Consistent, predictable behavior test run Documenting a Test Run

Comments

@glasnt
Copy link
Contributor

glasnt commented Oct 22, 2022

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)

Screen Shot 2022-10-22 at 12 11 55 pm

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:

Screen Shot 2022-10-22 at 12 45 45 pm


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:

@ehmatthes
Copy link
Owner

Thank you! See #155.

@glasnt
Copy link
Contributor Author

glasnt commented Oct 24, 2022

Pending creating a new issue for my new platform, I've completed all my tasks, so once I have that thread going I can close this issue.

@ehmatthes ehmatthes added the test run Documenting a Test Run label Oct 27, 2022
@ehmatthes
Copy link
Owner

ehmatthes commented Nov 13, 2022

0.5.8 fixes the issue with static resources being made available for the admin site, and the larger whitenoise middleware issue. Thank you for the nice clean way to modify middleware as well! I also deployed your test project using 0.5.8, and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
heroku stability Consistent, predictable behavior test run Documenting a Test Run
Projects
None yet
Development

No branches or pull requests

2 participants