Skip to content

Commit 2f498e1

Browse files
authored
Merge pull request #1731 from nikhiljohn10/restructuting-proposal
Fixed #1694
2 parents de6ea47 + a1eb648 commit 2f498e1

File tree

5 files changed

+107
-112
lines changed

5 files changed

+107
-112
lines changed

SUMMARY.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

en/deploy/README.md

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -172,99 +172,7 @@ Branch main set up to track remote branch main from origin.
172172

173173
Your code is now on GitHub. Go and check it out! You'll find it's in fine company – [Django](https://github.com/django/django), the [Django Girls Tutorial](https://github.com/DjangoGirls/tutorial), and many other great open source software projects also host their code on GitHub. :)
174174

175-
176-
# Setting up our blog on PythonAnywhere
177-
178-
## Sign up for a PythonAnywhere account
179-
180-
> **Note** You might have already created a PythonAnywhere account earlier during the install steps – if so, no need to do it again.
181-
182-
{% include "/deploy/signup_pythonanywhere.md" %}
183-
184-
185-
## Configuring our site on PythonAnywhere
186-
187-
Go back to the main [PythonAnywhere Dashboard](https://www.pythonanywhere.com/) by clicking on the logo, and choose the option to start a "Bash" console – that's the PythonAnywhere version of a command line, just like the one on your computer.
188-
189-
![The 'New Console' section on the PythonAnywhere web interface, with a button for 'bash'](images/pythonanywhere_bash_console.png)
190-
191-
> **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.
192-
193-
Deploying a web app on PythonAnywhere involves pulling down your code from GitHub, and then configuring PythonAnywhere to recognise it and start serving it as a web application. There are manual ways of doing it, but PythonAnywhere provides a helper tool that will do it all for you. Let's install it first:
194-
195-
{% filename %}PythonAnywhere command-line{% endfilename %}
196-
```
197-
$ pip3.8 install --user pythonanywhere
198-
```
199-
200-
That should print out some things like `Collecting pythonanywhere`, and eventually end with a line saying `Successfully installed (...) pythonanywhere- (...)`.
201-
202-
Now we run the helper to automatically configure our app from GitHub. Type the following into the console on PythonAnywhere (don't forget to use your GitHub username in place of `<your-github-username>`, so that the URL matches the clone URL from GitHub):
203-
204-
{% filename %}PythonAnywhere command-line{% endfilename %}
205-
```
206-
$ pa_autoconfigure_django.py --python=3.8 https://github.com/<your-github-username>/my-first-blog.git
207-
```
208-
209-
As you watch that running, you'll be able to see what it's doing:
210-
211-
- Downloading your code from GitHub
212-
- Creating a virtualenv on PythonAnywhere, just like the one on your own computer
213-
- Updating your settings file with some deployment settings
214-
- Setting up a database on PythonAnywhere using the `manage.py migrate` command
215-
- Setting up your static files (we'll learn about these later)
216-
- And configuring PythonAnywhere to serve your web app via its API
217-
218-
On PythonAnywhere all those steps are automated, but they're the same steps you would have to go through with any other server provider.
219-
220-
The main thing to notice right now is that your database on PythonAnywhere is actually totally separate from your database on your own computer, so it can have different posts and admin accounts. As a result, just as we did on your own computer, we need to initialize the admin account with `createsuperuser`. PythonAnywhere has automatically activated your virtualenv for you, so all you need to do is run:
221-
222-
{% filename %}PythonAnywhere command-line{% endfilename %}
223-
```
224-
(ola.pythonanywhere.com) $ python manage.py createsuperuser
225-
```
226-
227-
Type in the details for your admin user. Best to use the same ones as you're using on your own computer to avoid any confusion, unless you want to make the password on PythonAnywhere more secure.
228-
229-
Now, if you like, you can also take a look at your code on PythonAnywhere using `ls`:
230-
231-
{% filename %}PythonAnywhere command-line{% endfilename %}
232-
```
233-
(ola.pythonanywhere.com) $ ls
234-
blog db.sqlite3 manage.py mysite requirements.txt static
235-
(ola.pythonanywhere.com) $ ls blog/
236-
__init__.py __pycache__ admin.py apps.py migrations models.py
237-
tests.py views.py
238-
```
239-
240-
You can also go to the "Files" page and navigate around using PythonAnywhere's built-in file browser. (From the Console page, you can get to other PythonAnywhere pages from the menu button in the upper right corner. Once you're on one of the pages, there are links to the other ones near the top.)
241-
242-
243-
## You are now live!
244-
245-
Your site should now be live on the public Internet! Click through to the PythonAnywhere "Web" page to get a link to it. You can share this with anyone you want. :)
246-
247-
248-
> **Note** This is a beginners' tutorial, and in deploying this site we've taken a few shortcuts which aren't ideal from a security point of view. If and when you decide to build on this project, or start a new project, you should review the [Django deployment checklist](https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/) for some tips on securing your site.
249-
250-
251-
## Debugging tips
252-
253-
254-
If you see an error while running the `pa_autoconfigure_django.py` script, here are a few common causes:
255-
256-
- Forgetting to create your PythonAnywhere API token.
257-
- Making a mistake in your GitHub URL
258-
- If you see an error saying *"Could not find your settings.py"*, it's probably because you didn't manage to add all your files to Git, and/or you didn't push them up to GitHub successfully. Have another look at the Git section above
259-
- If you previously signed up for a PythonAnywhere account and had an error with collectstatic, you probably have an older version of SQLite (eg 3.8.2) for your account. In that case, sign up for a new account and try the commands in the PythonAnywhere section above.
260-
261-
262-
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" page](https://www.pythonanywhere.com/web_app_setup/). See if there are any error messages in there; the most recent ones are at the bottom.
263-
264-
There are also some [general debugging tips on the PythonAnywhere help site](http://help.pythonanywhere.com/pages/DebuggingImportError).
265-
266-
And remember, your coach is here to help!
267-
175+
{% include "/deploy/pythonanywhere.md" %}
268176

269177
# Check out your site!
270178

en/deploy/pythonanywhere.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Setting up our blog on PythonAnywhere
2+
3+
## Sign up for a PythonAnywhere account
4+
5+
> **Note** You might have already created a PythonAnywhere account earlier during the install steps – if so, no need to do it again.
6+
{% include "/deploy/signup_pythonanywhere.md" %}
7+
8+
9+
## Configuring our site on PythonAnywhere
10+
11+
Go back to the main [PythonAnywhere Dashboard](https://www.pythonanywhere.com/) by clicking on the logo, and choose the option to start a "Bash" console – that's the PythonAnywhere version of a command line, just like the one on your computer.
12+
13+
![The 'New Console' section on the PythonAnywhere web interface, with a button for 'bash'](images/pythonanywhere_bash_console.png)
14+
15+
> **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.
16+
Deploying a web app on PythonAnywhere involves pulling down your code from GitHub, and then configuring PythonAnywhere to recognise it and start serving it as a web application. There are manual ways of doing it, but PythonAnywhere provides a helper tool that will do it all for you. Let's install it first:
17+
18+
{% filename %}PythonAnywhere command-line{% endfilename %}
19+
```
20+
$ pip{{ book.pa_py_version }} install --user pythonanywhere
21+
```
22+
23+
That should print out some things like `Collecting pythonanywhere`, and eventually end with a line saying `Successfully installed (...) pythonanywhere- (...)`.
24+
25+
Now we run the helper to automatically configure our app from GitHub. Type the following into the console on PythonAnywhere (don't forget to use your GitHub username in place of `<your-github-username>`, so that the URL matches the clone URL from GitHub):
26+
27+
{% filename %}PythonAnywhere command-line{% endfilename %}
28+
```
29+
$ pa_autoconfigure_django.py --python={{ book.pa_py_version }} https://github.com/<your-github-username>/my-first-blog.git
30+
```
31+
32+
As you watch that running, you'll be able to see what it's doing:
33+
34+
- Downloading your code from GitHub
35+
- Creating a virtualenv on PythonAnywhere, just like the one on your own computer
36+
- Updating your settings file with some deployment settings
37+
- Setting up a database on PythonAnywhere using the `manage.py migrate` command
38+
- Setting up your static files (we'll learn about these later)
39+
- And configuring PythonAnywhere to serve your web app via its API
40+
41+
On PythonAnywhere all those steps are automated, but they're the same steps you would have to go through with any other server provider.
42+
43+
The main thing to notice right now is that your database on PythonAnywhere is actually totally separate from your database on your own computer, so it can have different posts and admin accounts. As a result, just as we did on your own computer, we need to initialize the admin account with `createsuperuser`. PythonAnywhere has automatically activated your virtualenv for you, so all you need to do is run:
44+
45+
{% filename %}PythonAnywhere command-line{% endfilename %}
46+
```
47+
(ola.pythonanywhere.com) $ python manage.py createsuperuser
48+
```
49+
50+
Type in the details for your admin user. Best to use the same ones as you're using on your own computer to avoid any confusion, unless you want to make the password on PythonAnywhere more secure.
51+
52+
Now, if you like, you can also take a look at your code on PythonAnywhere using `ls`:
53+
54+
{% filename %}PythonAnywhere command-line{% endfilename %}
55+
```
56+
(ola.pythonanywhere.com) $ ls
57+
blog db.sqlite3 manage.py mysite requirements.txt static
58+
(ola.pythonanywhere.com) $ ls blog/
59+
__init__.py __pycache__ admin.py apps.py migrations models.py
60+
tests.py views.py
61+
```
62+
63+
You can also go to the "Files" page and navigate around using PythonAnywhere's built-in file browser. (From the Console page, you can get to other PythonAnywhere pages from the menu button in the upper right corner. Once you're on one of the pages, there are links to the other ones near the top.)
64+
65+
66+
## You are now live!
67+
68+
Your site should now be live on the public Internet! Click through to the PythonAnywhere "Web" page to get a link to it. You can share this with anyone you want. :)
69+
70+
71+
> **Note** This is a beginners' tutorial, and in deploying this site we've taken a few shortcuts which aren't ideal from a security point of view. If and when you decide to build on this project, or start a new project, you should review the [Django deployment checklist](https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/) for some tips on securing your site.
72+
73+
## Debugging tips
74+
75+
76+
If you see an error while running the `pa_autoconfigure_django.py` script, here are a few common causes:
77+
78+
- Forgetting to create your PythonAnywhere API token.
79+
- Making a mistake in your GitHub URL
80+
- If you see an error saying *"Could not find your settings.py"*, it's probably because you didn't manage to add all your files to Git, and/or you didn't push them up to GitHub successfully. Have another look at the Git section above
81+
- If you previously signed up for a PythonAnywhere account and had an error with collectstatic, you probably have an older version of SQLite (eg 3.8.2) for your account. In that case, sign up for a new account and try the commands in the PythonAnywhere section above.
82+
83+
84+
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" page](https://www.pythonanywhere.com/web_app_setup/). See if there are any error messages in there; the most recent ones are at the bottom.
85+
86+
There are also some [general debugging tips on the PythonAnywhere help site](http://help.pythonanywhere.com/pages/DebuggingImportError).
87+
88+
And remember, your coach is here to help!

en/python_introduction/README.md

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,7 @@
66
77
Let's write some code!
88

9-
## Python prompt
10-
11-
> For readers at home: this part is covered in the [Python Basics: Integers, Strings, Lists, Variables and Errors](https://www.youtube.com/watch?v=MO63L4s-20U) video.
12-
13-
To start playing with Python, we need to open up a *command line* on your computer. You should already know how to do that – you learned it in the [Intro to Command Line](../intro_to_command_line/README.md) chapter.
14-
15-
Once you're ready, follow the instructions below.
16-
17-
We want to open up a Python console, so type in `python` on Windows or `python3` on Mac OS/Linux and hit `enter`.
18-
19-
{% filename %}command-line{% endfilename %}
20-
```
21-
$ python3
22-
Python {{ book.py_release }} (...)
23-
Type "help", "copyright", "credits" or "license" for more information.
24-
>>>
25-
```
9+
{% include "/python_introduction/prompt.md" %}
2610

2711
## Your first Python command!
2812

en/python_introduction/prompt.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Python prompt
2+
3+
> For readers at home: this part is covered in the [Python Basics: Integers, Strings, Lists, Variables and Errors](https://www.youtube.com/watch?v=MO63L4s-20U) video.
4+
5+
To start playing with Python, we need to open up a *command line* on your computer. You should already know how to do that – you learned it in the [Intro to Command Line](../intro_to_command_line/README.md) chapter.
6+
7+
Once you're ready, follow the instructions below.
8+
9+
We want to open up a Python console, so type in `python` on Windows or `python3` on Mac OS/Linux and hit `enter`.
10+
11+
{% filename %}command-line{% endfilename %}
12+
```
13+
$ python3
14+
Python {{ book.py_release }} (...)
15+
Type "help", "copyright", "credits" or "license" for more information.
16+
>>>
17+
```

0 commit comments

Comments
 (0)