Heroku Application Error while Deploying Django application - django

enter image description here
Please help me with this error

It may be due to your static files.
Try the following:
heroku config:set DISABLE_COLLECTSTATIC=1
git push heroku main
heroku run python manage.py migrate
heroku run 'bower install --config.interactive=false;grunt
prep;python
manage.py collectstatic --noinput'
heroku config:unset DISABLE_COLLECTSTATIC
heroku run python manage.py collectstatic
Hope this helps.
I can also see the console says: could not find module 'whitenoise'. Have you set your requirements.txt properly?

Related

Django data was not brought to heroku

I have Django apps, which include users and posts models. The apps work perfectly at local following making migrations and migrating. I tried two different ways to deploy the apps to Heroku. First, using Heroku Git, the apps works on Heroku the same as at local.
When using GitHub, however, all data were not brought to Heroku. I tried to run "python manage.py makemigrations" and "python manage.py migrate" on Heroku, but the data from local was not brought still.
I would really appreciate it if you could please explain and help with the issue using GitHub.
I think you have to migrate on Heroku as well, try:
heroku run python manage.py migrate
See the heroku docs
check your .gitignore file maybe db.sqlite in gitignore file and you can remove it
another option is dumpdata and load in production
you can run
python3 manage.py dumpdata > data.json
and load data in production
python3 manage.py loaddata data.json

Django on Heroku - ProgrammingError at / relation "..." does not exist

I'm getting this error. I know you usually get this error because the databases wasn't properly migrated.
When I run heroku local web, the website works fine when I go to localhost:5000.
However after I deploy the app to heroku with git push heroku master, the error comes up.
In other words, it works in my local environment. But it does not work after deploying to heroku.
I have Heroku-Postgres installed as an add-on in heroku.
What could be causing this?
excute migrations and makemigrations in bash heroku. open the terminal in the local project folder and give the following commands:
heroku run bash
~$ ./manage.py makemigrations
~$ ./manage.py migrate
~$ exit
The following steps did it for me
Make all the necessary migrations (python manage.py makemigrations) and migrate (python manage.py migrate) locally,
push to heroku master
and finally running heroku run python manage.py migrate
Solved the issue
I experienced the same error after making a change to a model and then deploying this change to heroku.
The only way I managed to fix this problem was to do the following:
Reset the database in heroku
Delete the migrations files from the migrations folder for the broken app locally (but keep the directory and the __init__.py file)
Run python manage.py makemigrations and python manage.py migrate. This will repopulate the migrations folder with clean migration files.
Push changes to master (ensure that you do not have migrations directories in .gitignore files.
Deploy changes to heroku
Run the heroku shell heroku run bash
Run python manage.py migrate
I was able to do this because my tables did not have much data in, but I would try to avoid resetting the database if I had more data in my tables.

Deploying Django app to Heroku via CircleCI: How to migrate database?

How can I run python manage.py makemigrations and python manage.py migrate automatically when deploying a Django app to Heroku via CircleCI. It seems all commands run local to CircleCI, but not on the deployed application in production.
Is there a way?
python manage.py makemigrations should be running locally, and you may commit the migration files along with the code.
Regaridng the migrations, open your Procfile and add this line: release: python manage.py migrate.
This will tell Heroku to migrate before deploying a new version of your code.

Heroku error "! Authentication failure"

I have deployed a django app on heroku and it is working fine. But I want to run the command "python manage.py makemigrations" but it is giving me authentication error.
I am using command: "heroku run python manage.py makemigrations"
I have used my credentials correctly as I am able to use "git push heroku master".
Terminal output:
$ heroku run python manage.py makemigrations
Running `python manage.py makemigrations` attached to terminal... up, run.3514
! Authentication error

Change path to manage.py when running Git Push Heroku Master

I just deployed Askbot forum to heroku successfully, but sometimes when running 'git push heroku master', the automatic collectstatic process fails (to me it looks like a random failure), prompting:
-----> Python app detected
-----> Installing dependencies with pip
Cleaning up...
-----> Preparing static assets
Collectstatic configuration error. To debug, run:
$ heroku run python ./askbot/setup_templates/manage.py collectstatic --noinput`
Well I don't really know if that's the problem, but the manage.py in .askbot/setup_templates/ contains the app's native version of the file, not the one I'm using for deployment, which is located in the app's root.
How could I make git push heroku master use the right manage.py file?
Change the path in your Procfile. Typically its something like this:
web: gunicorn hellodjango.wsgi --log-file -
Adjust it:
# from:
web: gunicorn .askbot/setup_templates/yourApp.wsgi
# to:
web: gunicorn .askbot/yourApp.wsgi
to check if the path was indeed your problem run this from the terminal:
heroku run python ./manage.py collectstatic
# or
heroku run python ./yourApp.wsgi collectstatic
Deleting or renaming Manage.py in askbot/setup_templates/ solved the problem.
Git Push Heroku Master never fails whan running collectstatic ever after.
so I believe that for some reason, probably because of sys.path configuration sometimes
Git Push Heroku Master first discovered and used ./askbot/setup_templates/manage.py instead of ./manage.py (which was the right one), and encountered an ImportError.