How to restart my Heroku Django app at the command line? - python

I deleted my app from Heroku web and now I want to recreate again but it says that it keeps the old name. I want to do:
heroku create globalnewstt
but it says:
No such app as peaceful-taiga-6373
(The last name and I deleted that repo from Heroku web)
How can I solve this problem?

You have your old Heroku app in your .git/config file. To fix this, run the command:
$ git remote rm heroku
Then, create your app fresh using heroku create =)

Related

How to upload python modules on Heroku

I have Django app, which I deployed on Heroku.
All the modules were deployed whith requirements.txt and everything is ok
But I also have several classes which are made as modules in separate .py files. On local machine these modules are in ...\Python\Python38-32\Lib\site-packages\modules\ folder
Now I need to upload these modules to Heroku. But I don't know how to do it. Is there any file manager program for windows, which allows to connect to heroku server and upload these /modules/ folder to the site-packages directory?
I've tried to find such a program, but couldn't find anything
Deploy the app
In this step you will deploy the app to Heroku.
Create an app on Heroku, which prepares Heroku to receive your source code:
$ heroku create
When you create an app, a git remote (called heroku) is also created and associated with your local git repository.
Heroku generates a random name (in this case serene-caverns-82714) for your app, or you can pass a parameter to specify your own app name.
Now deploy your code:
$ git push heroku master
The application is now deployed. Ensure that at least one instance of the app is running:
$ heroku ps:scale web=1
Now visit the app at the URL generated by its app name. As a handy shortcut, you can open the website as follows:
$ heroku open

How to upload and deploy django cookiecutter project, with docker, to heroku?

I am developing an app with django cookiecutter (with docker and heroku setup) and have come so far as to deploying it. This is my first ever project, so no prior experience with django, docker or heroku. I've read up on it at cookiecutter docs, heroku and a little on the docker website but I still don't how to deploy.
I have downloaded the heroki cli , have set up app on heroku with my own domain and a postgres db and I am planning on getting hobby tier to get the automated certificate. All environment variables are set in the .env file and are set in the heroku config vars in my app at heoku. So everything should be alright as far as code and settings. I am also using git as version control.
Am I supposed to upload the whole project (code, settings, docker files etc) to heroku with git or by some other means? I saw there was an option to deploy the project with docker deploys aswell at herokus website. What option is the correct one?
I was thinking initially that I would just upload the project through git and run docker-compose -f production.yml up (in the heroku bash)... or something like that and that. I dont know, please help.
If some info is missing or is unclear I will try edit it as best as I can.
It is better to deploy the project to Heroku using git.
$ heroku login
$ heroku create your_custom_app_name
$ git add --a
$ git commit -m "My custom app deployment to heroku"
$ git push heroku master
and then once it is deployed.
$ heroku python manage.py migrate

Updating heroku django deployed site with new commits to github repo

Say I have deployed a django website on heroku through a github repository. (For deployment I simply clicked on the deploy button here - https://github.com/AmmsA/theresumator#theresumator---using-django-resumator.) I now update the repository with new commits.
Q: How can I make changes in the deployed website from the repository without losing the data already present on the repository.
When you are pushing the fresh commits git push heroku master or via git hook git push origin master -- these nothing to do with heroku database.
But this will run this command when build python manage.py migrate so if you are changed something in the migrations definetly db schema get alter not the values stored in there.
Just set your remote project:
heroku git:remote -a
And then, push your project on Heroku:
git push heroku main
I've written an article on it. You can see that. https://medium.com/#sreebash/how-to-update-previous-deployed-project-on-heroku-c778d555cd8a

Deploy a pre existing django git repo to heroku

I have a DJango git repository.Me and some other developers are working on it and it has multiple branchs also. Now i want to deploy it to Heroku or want to use the heroku as a staging server means before pushing to git i want to push the code changes to heroku and if verified will push changes to git. For this i have created a heroku app using this git repo by running
heroku create
command for heruku. But the problem is when i make a commit it is directly committed to the git not to the heroku.
I have tried to delete the heroku app from the local git repo by running
`heroku apps:destroy –a guarded-tundra-1589 --confirm`
but when i again tried to push the heroku master code is pushed to it. means it doesn't get deleted.
Tell me the right way to deploy the project which already has a git repo to heroku.
There are standart Heroku commands to do this:
$ heroku auth:login
... output omitted ...
$ heroku create --stack cedar
... output omitted ...
$ git commit -a -m 'Mods to run on Heroku.'
$ git push heroku master
UPDATE:
Also if you are planning to use Heroku in future it could be useful frt you to check their official Documentation - Getting Started with Django on Heroku
This will delete your repo, but this what worked for me when I got that error.
rm -rf .git
git init
git add .
git commit -m "First commit"
heroku create --stack cedar
git push heroku master

How to make South works in Heroku for a Django app

I am working on Python/Django and I am trying to use South to manage my database. In local environment is working great. The problem comes when I deploy to Heroku. The issue is that when I create a migration with
$heroku run manage.py schemamigration mydjangoapp
It looks like it works (the shell confirmed it), however, then I try to use migrations and it won't work. When I do:
$heroku run python manage.py migrate mydjangoapp
I get this;
The app 'createtuto' does not appear to use migrations
I checked on the problem and it looks like heroku doesn't allow South to create the migration directory at /myDjangoapp/migrations.
Is there anything I can do to make it work?
I tried to use convert_to_south, but I got the same results: At the beginning it looks like it worked, but It did not, not migration created.
When you run 'heroku run' it connects to an isolated instance of your deployed environment. It does create the migration, however that migration is not contained within your slug. Each time you do a 'git push heroku master' it installs your dependencies and packages your application into a slug. This is more or less a tarball of your application which enables Heroku to easily deploy it to new dynos as you scale up.
In order to run a migration on Heroku you would create the migration locally, check it in, then run the migration on heroku. Something similar to:
manage.py schemamigration mydjangoapp
git add mydjangoapp/migrations/*
git commit -m 'adding new migrations'
git push heroku master
heroku run python manage.py migrate mydjangoapp
I follow the direction from Mike Ball here successfully:
http://www.mikeball.us/blog/using-south-on-heroku/
Like CraigKerstiens answer said, you should make the migration locally first then push to heroku. Before you make a migration on Heroku, make sure you convert your Heroku instance into south, for example
heroku run bin/python django_project/manage.py convert_to_south django_app

Categories