Skip to content

Commit 55f498c

Browse files
author
Paul Hallett
committed
Put deploy! chapter through hemingwayapp
1 parent 058e814 commit 55f498c

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

en/deploy/README.md

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Until now your website was only available on your computer, now you will learn how to deploy it! Deploying is the process of publishing your application on the Internet so people can finally go and see your app :).
66

7-
As you learned, a website has to be located on a server. There are a lot of providers, but we will use one that has a relatively simple deployment process: [PythonAnywhere](http://pythonanywhere.com/). PythonAnywhere is free for small applications that don't have too many visitors, it'll definitely be enough for you now.
7+
As you learned, a website has to be located on a server. There are a lot of server providers available on the internet. We will use one that has a relatively simple deployment process: [PythonAnywhere](http://pythonanywhere.com/). PythonAnywhere is free for small applications that don't have too many visitors so it'll definitely be enough for you now.
88

99
The other external service we'll be using is [GitHub](http://www.github.com), which is a code hosting service. There are others out there, but almost all programmers have a GitHub account these days, and now so will you!
1010

@@ -13,7 +13,7 @@ We'll use GitHub as a stepping stone to transport our code to and from PythonAny
1313

1414
# Git
1515

16-
Git is a "version control system" used by a lot of programmers - software which tracks changes to files over time so that you can recall specific versions later. A bit like "track changes" in Microsoft Word, but much more powerful.
16+
Git is a "version control system" used by a lot of programmers. This software can track changes to files over time so that you can recall specific versions later. A bit like the "track changes" feature in Microsoft Word, but much more powerful.
1717

1818

1919
## Installing Git
@@ -49,7 +49,7 @@ And save it as `.gitignore` in the top-level "djangogirls" folder.
4949

5050
> **Note** The dot at the beginning of the file name is important! If you're having any difficulty creating it (Macs don't like you to create files that begin with a dot via the Finder, for example), then use the "Save As" feature in your editor, it's bulletproof.
5151
52-
It's a good idea to use a `git status` command before `git add` or whenever you find yourself unsure of what will be done, to prevent any surprises from happening (e.g. wrong files will be added or commited). The `git status` command returns information about any untracked/modifed/staged files, branch status and much more. The output should be similar to:
52+
It's a good idea to use a `git status` command before `git add` or whenever you find yourself unsure of what has changed. This will help stop any surprises from happening, such as wrong files being added or commited. The `git status` command returns information about any untracked/modifed/staged files, branch status, and much more. The output should be similar to:
5353

5454
$ git status
5555
On branch master
@@ -93,12 +93,12 @@ On the next screen, you'll be shown your repo's clone URL. Choose the "HTTPS" ve
9393

9494
Now we need to hook up the Git repository on your computer to the one up on GitHub.
9595

96-
Type the following into your console (Replace `<your-github-username>` with the username you entered when you created your GitHub account, and there should be no angle-brackets):
96+
Type the following into your console (Replace `<your-github-username>` with the username you entered when you created your GitHub account, but without the angle-brackets):
9797

9898
$ git remote add origin https://github.com/<your-github-username>/my-first-blog.git
9999
$ git push -u origin master
100100

101-
Enter your GitHub username and password, and you should see something like this:
101+
Enter your GitHub username and password and you should see something like this:
102102

103103
Username for 'https://github.com': hjwp
104104
Password for 'https://[email protected]':
@@ -123,15 +123,15 @@ Your code is now on GitHub. Go and check it out! You'll find it's in fine compa
123123

124124
## Pulling our code down on PythonAnywhere
125125

126-
When you've signed up for PythonAnywhere, you'll be taken to your dashboard or "Consoles" page. Choose the option to start a "Bash" console -- that's the PythonAnywhere version of a console, just like the one on your PC
126+
When you've signed up for PythonAnywhere, you'll be taken to your dashboard or "Consoles" page. Choose the option to start a "Bash" console -- that's the PythonAnywhere version of a console, just like the one on your computer.
127127

128128
> **Note** PythonAnywhere is based on Linux, so if you're on Windows, the console will look a little different from the one on your computer.
129129
130-
Let's pull down our code from GitHub onto PythonAnywhere by creating a "clone" of the repo. Type this into the console on PythonAnywhere (don't forget to use your GitHub username in place of `<your-github-username>`:
130+
Let's pull down our code from GitHub and onto PythonAnywhere by creating a "clone" of our repo. Type the following into the console on PythonAnywhere (don't forget to use your GitHub username in place of `<your-github-username>`):
131131

132132
$ git clone https://github.com/<your-github-username>/my-first-blog.git
133133

134-
This will pull down a copy of your code onto PythonAnywhere. Check it out by typing:
134+
This will pull down a copy of your code onto PythonAnywhere. Check it out by typing `tree my-first-blog`:
135135

136136
$ tree my-first-blog
137137
my-first-blog/
@@ -180,12 +180,11 @@ Successfully installed django-1.8.2 whitenoise-2.0
180180

181181
### Collecting static files.
182182

183-
Were you wondering what "whitenoise" thing was? It's a tool for serve so-called "static files". Static files work differently on servers compared to on our own computer, and we need a tool like "whitenoise" to serve them.
183+
Were you wondering what the "whitenoise" thing was? It's a tool for serving so-called "static files". Static files are the files that don't regularly change or don't run programming code, such as HTML or CSS files. They work differently on servers compared to on our own computer and we need a tool like "whitenoise" to serve them.
184184

185185
We'll find out a bit more about static files later in the tutorial, when we edit the CSS for our site.
186186

187-
For now we just need to run an extra command called `collectstatic`, on the server. It tells Django to gather up all the static files it needs on the server. Mostly, these are the static files that make the admin site look pretty at the moment.
188-
187+
For now we just need to run an extra command called `collectstatic`, on the server. It tells Django to gather up all the static files it needs on the server. At the moment these are mostly files that make the admin site look pretty.
189188

190189
$ python manage.py collectstatic
191190

@@ -211,9 +210,9 @@ Type "yes", and away it goes! Don't you love making computers print out pages a
211210

212211
### Creating the database on PythonAnywhere
213212

214-
Here's another thing that's different between your own computer and the server -- it uses a different database. So, the user accounts and posts can be different on the server and on your computer.
213+
Here's another thing that's different between your own computer and the server: it uses a different database. So the user accounts and posts can be different on the server and on your computer.
215214

216-
So we initialise the database on the server just like we did the one on your own computer, with `migrate` and `createsuperuser`:
215+
We can initialise the database on the server just like we did the one on your own computer, with `migrate` and `createsuperuser`:
217216

218217

219218
(mvenv) $ python manage.py migrate
@@ -227,11 +226,11 @@ So we initialise the database on the server just like we did the one on your own
227226

228227
## Publishing our blog as a web app
229228

230-
Now our code is on PythonAnywhere, our virtualenv is ready, the static files are collected, and the database is initialised, we're ready to publish it as a web app.
229+
Now our code is on PythonAnywhere, our virtualenv is ready, the static files are collected, and the database is initialised. We're ready to publish it as a web app!
231230

232-
Click back to the PythonAnywhere dashboard by clicking on its logo, and go click on the **Web** tab, and hit **Add a new web app**.
231+
Click back to the PythonAnywhere dashboard by clicking on its logo, and go click on the **Web** tab. Finally, hit **Add a new web app**.
233232

234-
In the dialog, after confirming your domain name, choose **manual configuration** (NB *not* the "Django" option). Next, choose **Python 3.4**, and click Next to finish the wizard.
233+
After confirming your domain name, choose **manual configuration** (NB *not* the "Django" option) in the dialog. Next choose **Python 3.4**, and click Next to finish the wizard.
235234

236235
> **Note** Make sure you choose the "Manual configuration" option, not the "Django" one. We're too cool for the default PythonAnywhere Django setup ;-)
237236
@@ -250,11 +249,11 @@ In the "Virtualenv" section, click the red text that says "Enter the path to a v
250249

251250
### Configuring the WSGI file
252251

253-
Django works using the "WSGI protocol", a standard for serving websites using Python, which PythonAnywhere supports. The way we configure PythonAnywhere to recognise our Django blog is by editing a WSGI configuration file.
252+
Django works using the "WSGI protocol", a standard for serving websites using Python, which PythonAnywhere supports. The way we configure PythonAnywhere to recognise our Django blog is by editing a WSGI configuration file.
254253

255254
Click on the "WSGI configuration file" link (in the "Code" section near the top of the page -- it'll be named something like `/var/www/<your-username>_pythonanywhere_com_wsgi.py`), and you'll be taken to an editor.
256255

257-
Delete all the current contents, and replace them with something like this:
256+
Delete all the contents and replace them with something like this:
258257

259258
```python
260259
import os
@@ -275,33 +274,33 @@ application = DjangoWhiteNoise(get_wsgi_application())
275274
276275
This file's job is to tell PythonAnywhere where our web app lives and what the Django settings file's name is. It also sets up the "whitenoise" static files tool.
277276

278-
Hit **Save**, and then go back to the **Web** tab.
277+
Hit **Save** and then go back to the **Web** tab.
279278

280-
We're all done! Hit the big green **Reload** button and you'll be able to go view your application. You'll find a link to it at the top of the page.
279+
We're all done! Hit the big green **Reload** button and you'll be able to go view your application. You'll find a link to it at the top of the page.
281280

282281

283282
## Debugging tips
284283

285-
If you see an error when you try to visit your site, the first place to look for some debugging info is in your **error log** -- you'll find a link to this on the PythonAnywhere [Web tab](https://www.pythonanywhere.com/web_app_setup/). See if there are any error messages in there; the most recent ones are at the bottom. Common problems include:
284+
If you see an error when you try to visit your site, the first place to look for some debugging info is in your **error log**. You'll find a link to this on the PythonAnywhere [Web tab](https://www.pythonanywhere.com/web_app_setup/). See if there are any error messages in there; the most recent ones are at the bottom. Common problems include:
286285

287-
- Forgetting one of the steps we did in the console: creating the virtualenv, activating it, installing Django into it, running collectstatic, migrating the database
286+
- Forgetting one of the steps we did in the console: creating the virtualenv, activating it, installing Django into it, running collectstatic, migrating the database.
288287

289-
- Making a mistake in the virtualenv path on the Web tab -- there will usually be a little red error message on there, if there is a problem
288+
- Making a mistake in the virtualenv path on the Web tab -- there will usually be a little red error message on there, if there is a problem.
290289

291290
- Making a mistake in the WSGI configuration file -- did you get the path to your my-first-blog folder right?
292291

293292
- Did you pick the same version of Python for your virtualenv as you did for your web app? Both should be 3.4.
294293

295-
- There are some [general debugging tips on the PythonAnywhere wiki](https://www.pythonanywhere.com/wiki/DebuggingImportError)
294+
- There are some [general debugging tips on the PythonAnywhere wiki](https://www.pythonanywhere.com/wiki/DebuggingImportError).
296295

297296
And remember, your coach is here to help!
298297

299298

300299
# You are live!
301300

302-
The default page for your site should say "Welcome to Django", just like it does on your local PC. Try adding `/admin/` to the end of the URL, and you'll be taken to the admin site. Log in with the username and password, and you'll see you can add new Posts on the server.
301+
The default page for your site should say "Welcome to Django", just like it does on your local computer. Try adding `/admin/` to the end of the URL, and you'll be taken to the admin site. Log in with the username and password, and you'll see you can add new Posts on the server.
303302

304303

305-
Give yourself a *HUGE* pat on the back -- server deployments are one of the trickiest parts of web development, and it often takes people several days before they get them working. But you've got your site live, on the real Internet, just like that!
304+
Give yourself a *HUGE* pat on the back! Server deployments are one of the trickiest parts of web development and it often takes people several days before they get them working. But you've got your site live, on the real Internet, just like that!
306305

307306

0 commit comments

Comments
 (0)