Skip to content

Commit

Permalink
Revert "Fixed #41 -- Deploying to Heroku without git"
Browse files Browse the repository at this point in the history
This reverts commit 0d2bfa1.

Conflicts:
	deploy/README.md
  • Loading branch information
bmispelon committed Nov 15, 2014
1 parent ddc7f53 commit b989c1f
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ Then authenticate your Heroku account on your computer by running this command:

In case you don't have an SSH key this command will automatically create one. SSH keys are required to push code to the Heroku.

## Ignore some files
## Git

We don't want to send all of our project files to Heroku. Some of them, like `local_settings.py` or our database, need to stay only on our local computer. In order to tell Heroku which files should it ignore, we need to create a `.gitignore` file in our project main directory.
Heroku uses a git repository to manage your project files, so we need to use it too.

Create `.gitignore` file with the following content:

Expand All @@ -129,34 +129,41 @@ Create `.gitignore` file with the following content:
local_settings.py
db.sqlite3

and save it. The dot on the beginning of the file name is important!
and save it. The dot on the beginning of the file name is important! As you can see, we're now telling Heroku to ignore `local_settings.py` and don't download it, so it's only available on your computer (locally).

> __Note:__ Remember to replace `myvenv` with the name you gave your `virtualenv`!
__NOTE:__ Remember to replace `myvenv` with the name you gave your `virtualenv`!

Next, we’ll create a new git repository and save our changes. Go to your console and run these commands:

$ git init
Initialized empty Git repository in ~/djangogirls/.git/
$ git add .
$ git commit -m "My Django Girls app"
[master (root-commit) 2943412] My Django Girls
7 files changed, 230 insertions(+)
create mode 100644 .gitignore
create mode 100644 Procfile
create mode 100644 mysite/__init__.py
create mode 100644 mysite/settings.py
create mode 100644 mysite/urls.py
create mode 100644 mysite/wsgi.py
create mode 100644 manage.py
create mode 100644 requirements.txt
create mode 100644 runtime.txt

## Deploy to Heroku!

It was a lot of configuration and installing, right? But you only need to do that once! Now you can deploy:
It was a lot of configuration and installing, right? But you need to do that once! Now you can deploy!

It's as simple as running this command, replacing `djangogirlsblog` with your own application name:

$ heroku create djangogirlsblog

Because our application needs a database, let's create a free [PostgreSQL](http://www.postgresql.org) instance on Heroku. It's as simple as running this command:

$ heroku addons:add heroku-postgresql --app djangogirlsblog

> In addition to creating a database for us, this command will also configure our application with the information on how to connect to the database. This information will be read and used by `dj_database_url.config()` in our `mysite/settings.py file`.
One more thing: let's install [heroku-push plugin](https://github.com/ddollar/heroku-push) by running this command:

$ heroku plugins:install https://github.com/ddollar/heroku-push
> __Note__: Remember to replace `djangogirlsblog` with the name of your application on Heroku.
Now we can do a simple push to deploy our application:

$ git init
$ heroku push --app djangogirlsblog
This automatically added the Heroku remote for our app to our repository. Now we can do a simple git push to deploy our application:

> __Note__: Remember to replace `djangogirlsblog` with the name of your application on Heroku.
$ git push heroku master

## Visit your application

Expand All @@ -179,8 +186,10 @@ We created a new database on Heroku, but we also need to sync it:

$ heroku run python manage.py migrate --app djangogirlsblog

One final step; since the newly created database is empty, we need to create a new user so we can access the admin:
As you can see, there is an error. Heroku created a new database for us and it's empty. We also need to sync it:

$ heroku run python manage.py createsuperuser --app djangogirlsblog

You should now be able to see your website in a browser! Congrats :)!


0 comments on commit b989c1f

Please sign in to comment.