requirements.txtfile to tell Heroku what Python packages need to be installed on our server.
virtualenvactivated and type this:
djangogirlsdirectory and run this command:
requirements.txtwith a list of your installed packages (i.e. Python libraries that you are using, for example Django :)).
pip freezeoutputs a list of all the Python libraries installed in your virtualenv, and the
>takes the output of
pip freezeand puts it into a file. Try running
pip freezewithout the
> requirements.txtto see what happens!
djangogirlsdirectory and add this line:
webapplication, and we'll do that by running the command
gunicornis a program that's like a more powerful version of Django's
djangogirlsdirectory using your editor's "new file" command, and putting the following text (and nothing else!) inside:
mysite/local_settings.pyfile. It should contain your
DATABASEsetup from your
mysite/settings.pyfile. Just like that:
mysite/settings.pyin your editor and change/add the following lines:
MIDDLEWARElist make sure it is placed after the Django
SecurityMiddleware, and keep the other Django middlewares.
When running the Heroku toolbelt installation program on Windows make sure to choose "Custom Installation" when being asked which components to install. In the list of components that shows up after that please additionally check the checkbox in front of "Git and SSH".
On Windows you also must run the following command to add Git and SSH to your command prompt's
setx PATH "%PATH%;C:\Program Files\Git\bin". Restart the command prompt program afterwards to enable the change.
djangogirlsdirectory and add
local_settings.pyto it. We want git to ignore
local_settings, so it stays on our local computer and doesn't end up on Heroku.
[your blog's name].herokuapp.com, so we need to choose a name that nobody else has taken. This name doesn't need to be related to the Django
blogapp or to
mysiteor anything we've created so far. The name can be anything you want, but Heroku is quite strict as to what characters you can use: you're only allowed to use simple lowercase letters (no capital letters or accents), numbers, and dashes (
djangogirlsblogwith your own application name:
Note: Remember to replace
djangogirlsblogwith the name of your application on Heroku.
the-new-namewith the new name you want to use):
Note: Remember that after you change your application's name, you'll need to visit
[the-new-name].herokuapp.comto see your site.
heroku create, it automatically added the Heroku remote for our app to our repository. Now we can do a simple git push to deploy our application:
Note: This will probably produce a lot of output the first time you run it, as Heroku compiles and installs psycopg. You'll know it's succeeded if you see something like
https://yourapplicationname.herokuapp.com/ deployed to Herokunear the end of the output.
Procfile(we chose a
webprocess type earlier). We can now tell Heroku to start this
webprocess. Since our blog application is quite simple, we don't need too much power and so it's fine to run just one process. It's possible to ask Heroku to run more processes (by the way, Heroku calls these processes "Dynos" so don't be surprised if you see this term) but it will no longer be free.
Note: you will see an error page! We'll talk about that in a minute.
createsuperusercommands, just like we did on PythonAnywhere. This time, they come via a special command-line on our own computer,