You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: en/deploy/README.md
+25-26Lines changed: 25 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
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 :).
6
6
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.
8
8
9
9
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!
10
10
@@ -13,7 +13,7 @@ We'll use GitHub as a stepping stone to transport our code to and from PythonAny
13
13
14
14
# Git
15
15
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.
17
17
18
18
19
19
## Installing Git
@@ -49,7 +49,7 @@ And save it as `.gitignore` in the top-level "djangogirls" folder.
49
49
50
50
> **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.
51
51
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:
53
53
54
54
$ git status
55
55
On branch master
@@ -93,12 +93,12 @@ On the next screen, you'll be shown your repo's clone URL. Choose the "HTTPS" ve
93
93
94
94
Now we need to hook up the Git repository on your computer to the one up on GitHub.
95
95
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):
@@ -123,15 +123,15 @@ Your code is now on GitHub. Go and check it out! You'll find it's in fine compa
123
123
124
124
## Pulling our code down on PythonAnywhere
125
125
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.
127
127
128
128
> **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.
129
129
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>`):
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.
184
184
185
185
We'll find out a bit more about static files later in the tutorial, when we edit the CSS for our site.
186
186
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.
189
188
190
189
$ python manage.py collectstatic
191
190
@@ -211,9 +210,9 @@ Type "yes", and away it goes! Don't you love making computers print out pages a
211
210
212
211
### Creating the database on PythonAnywhere
213
212
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.
215
214
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`:
217
216
218
217
219
218
(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
227
226
228
227
## Publishing our blog as a web app
229
228
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!
231
230
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**.
233
232
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.
235
234
236
235
> **Note** Make sure you choose the "Manual configuration" option, not the "Django" one. We're too cool for the default PythonAnywhere Django setup ;-)
237
236
@@ -250,11 +249,11 @@ In the "Virtualenv" section, click the red text that says "Enter the path to a v
250
249
251
250
### Configuring the WSGI file
252
251
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.
254
253
255
254
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.
256
255
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:
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.
277
276
278
-
Hit **Save**, and then go back to the **Web** tab.
277
+
Hit **Save** and then go back to the **Web** tab.
279
278
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.
281
280
282
281
283
282
## Debugging tips
284
283
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:
286
285
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.
288
287
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.
290
289
291
290
- Making a mistake in the WSGI configuration file -- did you get the path to your my-first-blog folder right?
292
291
293
292
- Did you pick the same version of Python for your virtualenv as you did for your web app? Both should be 3.4.
294
293
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).
296
295
297
296
And remember, your coach is here to help!
298
297
299
298
300
299
# You are live!
301
300
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.
303
302
304
303
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!
0 commit comments