Skip to content

Commit 11212fd

Browse files
authored
Merge branch 'master' into crowdin-translation-sk
2 parents 8352c99 + fe36566 commit 11212fd

67 files changed

Lines changed: 2683 additions & 2096 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cs/deploy/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Git bude sledovat změny souborů a složek v tomto adresáři, ale jsou tam ně
4444
```
4545
*.pyc
4646
__pycache__
47-
myvenv
48-
db.sqlite3
47+
myvenv
48+
db.sqlite3
4949
.DS_Store
5050
```
5151

cs/django_models/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ from django.utils import timezone
115115

116116

117117
class Post(models.Model):
118-
author = models.ForeignKey('auth.User')
118+
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
119119
title = models.CharField(max_length=200)
120120
text = models.TextField()
121121
created_date = models.DateTimeField(

de/django_models/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ from django.utils import timezone
118118

119119

120120
class Post(models.Model):
121-
author = models.ForeignKey('auth.User')
121+
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
122122
title = models.CharField(max_length=200)
123123
text = models.TextField()
124124
created_date = models.DateTimeField(

en/deploy/README.md

Lines changed: 43 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ Enter your GitHub username and password and you should see something like this:
113113

114114
{% filename %}command-line{% endfilename %}
115115
```
116-
Username for 'https://github.com': hjwp
117-
Password for 'https://hjwp@github.com':
116+
Username for 'https://github.com': ola
117+
Password for 'https://ola@github.com':
118118
Counting objects: 6, done.
119119
Writing objects: 100% (6/6), 200 bytes | 0 bytes/s, done.
120120
Total 3 (delta 0), reused 0 (delta 0)
121-
To https://github.com/hjwp/my-first-blog.git
121+
To https://github.com/ola/my-first-blog.git
122122
* [new branch] master -> master
123123
Branch master set up to track remote branch master from origin.
124124
```
@@ -130,168 +130,99 @@ Your code is now on GitHub. Go and check it out! You'll find it's in fine compa
130130

131131
# Setting up our blog on PythonAnywhere
132132

133+
## Sign up for a PythonAnywhere account
134+
133135
> **Note** You might have already created a PythonAnywhere account earlier during the install steps – if so, no need to do it again.
134136
135137
{% include "/deploy/signup_pythonanywhere.md" %}
136138

137139

138-
## Pulling our code down on PythonAnywhere
140+
## Configuring our site on PythonAnywhere
139141

140-
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.
142+
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.
141143

142-
<img src="images/pythonanywhere_bash_console.png" alt="pointing at Other: Bash in Start a new Console" />
144+
<img src="images/pythonanywhere_bash_console.png" alt="Pointing at Bash in the New Console section" />
143145

144146
> **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.
145147
146-
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>`):
147-
148-
{% filename %}PythonAnywhere command-line{% endfilename %}
149-
```
150-
$ git clone https://github.com/<your-github-username>/my-first-blog.git
151-
```
152-
153-
This will pull down a copy of your code onto PythonAnywhere. Check it out by typing `tree my-first-blog`:
148+
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:
154149

155150
{% filename %}PythonAnywhere command-line{% endfilename %}
156151
```
157-
$ tree my-first-blog
158-
my-first-blog/
159-
├── blog
160-
│ ├── __init__.py
161-
│ ├── admin.py
162-
│ ├── migrations
163-
│ │ ├── 0001_initial.py
164-
│ │ └── __init__.py
165-
│ ├── models.py
166-
│ ├── tests.py
167-
│ └── views.py
168-
├── manage.py
169-
└── mysite
170-
├── __init__.py
171-
├── settings.py
172-
├── urls.py
173-
└── wsgi.py
152+
$ pip3.6 install --user pythonanywhere
174153
```
175154

155+
That should print out some things like `Collecting pythonanywhere`, and eventually end with a line saying `Successfully installed (...) pythonanywhere- (...)`.
176156

177-
### Creating a virtualenv on PythonAnywhere
178-
179-
Just like you did on your own computer, you can create a virtualenv on PythonAnywhere. In the Bash console, type:
157+
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>`):
180158

181159
{% filename %}PythonAnywhere command-line{% endfilename %}
182160
```
183-
$ cd my-first-blog
184-
185-
$ virtualenv --python=python3.6 myvenv
186-
Running virtualenv with interpreter /usr/bin/python3.6
187-
[...]
188-
Installing setuptools, pip...done.
189-
190-
$ source myvenv/bin/activate
191-
192-
(myvenv) $ pip install django~=1.11.0
193-
Collecting django
194-
[...]
195-
Successfully installed django-1.11.3
161+
$ pa_autoconfigure_django.py https://github.com/<your-github-username>/my-first-blog.git
196162
```
197163

164+
As you watch that running, you'll be able to see what it's doing:
198165

199-
> **Note** The `pip install` step can take a couple of minutes. Patience, patience! But if it takes more than five minutes, something is wrong. Ask your coach.
200-
201-
<!--TODO: think about using requirements.txt instead of pip install.-->
202-
203-
### Creating the database on PythonAnywhere
166+
- Downloading your code from GitHub
167+
- Creating a virtualenv on PythonAnywhere, just like the one on your own PC
168+
- Updating your settings file with some deployment settings
169+
- Setting up a database on PythonAnywhere using the `manage.py migrate` command
170+
- Setting up your static files (we'll learn about these later)
171+
- And configuring PythonAnywhere to serve your web app via its API
204172

205-
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.
173+
On PythonAnywhere all those steps are automated, but they're the same steps you would have to go through with any other server provider. The main thing to notice right now is that your database on PythonAnywhere is actually totally separate from your database on your own PC—that means it can have different posts and admin accounts.
206174

207-
Just as we did on your own computer, we repeat the step to initialize the database on the server, with `migrate` and `createsuperuser`:
175+
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:
208176

209177
{% filename %}PythonAnywhere command-line{% endfilename %}
210178
```
211-
(mvenv) $ python manage.py migrate
212-
Operations to perform:
213-
[...]
214-
Applying sessions.0001_initial... OK
215-
(mvenv) $ python manage.py createsuperuser
179+
(ola.pythonanywhere.com) $ python manage.py createsuperuser
216180
```
217181

218-
## Publishing our blog as a web app
219-
220-
Now our code is on PythonAnywhere, our virtualenv is ready, and the database is initialized. We're ready to publish it as a web app!
221-
222-
Click back to the PythonAnywhere dashboard by clicking on its logo, and then click on the **Web** tab. Finally, hit **Add a new web app**.
223-
224-
After confirming your domain name, choose **manual configuration** (N.B. – *not* the "Django" option) in the dialog. Next choose **Python 3.6**, and click Next to finish the wizard.
225-
226-
> **Note** Make sure you choose the "Manual configuration" option, not the "Django" one. We're too cool for the default PythonAnywhere Django setup. ;-)
182+
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.
227183

184+
Now, if you like, you can also take a look at your code on PythonAnywhere using `ls`:
228185

229-
### Setting the virtualenv
230-
231-
You'll be taken to the PythonAnywhere config screen for your webapp, which is where you'll need to go whenever you want to make changes to the app on the server.
232-
233-
<img src="images/pythonanywhere_web_tab_virtualenv.png" />
234-
235-
In the "Virtualenv" section, click the red text that says "Enter the path to a virtualenv", and enter `/home/<your-PythonAnywhere-username>/my-first-blog/myvenv/`. Click the blue box with the checkmark to save the path before moving on.
236-
237-
> **Note** Substitute your own PythonAnywhere username as appropriate. If you make a mistake, PythonAnywhere will show you a little warning.
238-
239-
240-
### Configuring the WSGI file
241-
242-
Django works using the "WSGI protocol", a standard for serving websites using Python, which PythonAnywhere supports. The way we configure PythonAnywhere to recognize our Django blog is by editing a WSGI configuration file.
243-
244-
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-PythonAnywhere-username>_pythonanywhere_com_wsgi.py`), and you'll be taken to an editor.
245-
246-
Delete all the contents and replace them with the following:
247-
248-
{% filename %}&lt;your-username&gt;_pythonanywhere_com_wsgi.py{% endfilename %}
249-
```python
250-
import os
251-
import sys
252-
253-
path = os.path.expanduser('~/my-first-blog')
254-
if path not in sys.path:
255-
sys.path.append(path)
256-
257-
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
258-
259-
from django.core.wsgi import get_wsgi_application
260-
from django.contrib.staticfiles.handlers import StaticFilesHandler
261-
application = StaticFilesHandler(get_wsgi_application())
186+
{% filename %}PythonAnywhere command-line{% endfilename %}
187+
```
188+
(ola.pythonanywhere.com) $ ls
189+
blog db.sqlite3 manage.py mysite static
190+
(ola.pythonanywhere.com) $ ls blog/
191+
__init__.py __pycache__ admin.py forms.py migrations models.py static
192+
templates tests.py urls.py views.py
262193
```
263194

264-
This file's job is to tell PythonAnywhere where our web app lives and what the Django settings file's name is.
195+
You can also go to the "Files" tab and navigate around using PythonAnywhere's built-in file browser.
265196

266-
The `StaticFilesHandler` is for dealing with our CSS. This is taken care of automatically for you during local development by the `runserver` command. We'll find out a bit more about static files later in the tutorial, when we edit the CSS for our site.
267197

268-
Hit **Save** and then go back to the **Web** tab.
198+
## You are now live!
269199

270-
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.
200+
Your site should now be live on the public Internet! Click through to the PythonAnywhere "Web" tab to get a link to it. You can share this with anyone you want :)
271201

272202

273203
## Debugging tips
274204

275-
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:
276205

277-
- Forgetting one of the steps we did in the console: creating the virtualenv, activating it, installing Django into it, migrating the database.
206+
If you see an error while running the `pa_autoconfigure_django.py` script, here are a few common causes:
278207

279-
- 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.
208+
- Forgetting to create your PythonAnywhere API token.
209+
- Making a mistake in your GitHub URL
210+
- 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
280211

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

283-
- Did you pick the same version of Python for your virtualenv as you did for your web app? Both should be 3.6.
213+
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.
284214

285-
There are also some [general debugging tips on the PythonAnywhere wiki](https://www.pythonanywhere.com/wiki/DebuggingImportError).
215+
There are also some [general debugging tips on the PythonAnywhere help site](http://help.pythonanywhere.com/pages/DebuggingImportError).
286216

287217
And remember, your coach is here to help!
288218

289219

290-
# You are live!
220+
# Check out your site!
291221

292222
The default page for your site should say "It worked!", 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.
293223

294224
Once you have a few posts created, you can go back to your local setup (not PythonAnywhere). From here you should work on your local setup to make changes. This is a common workflow in web development – make changes locally, push those changes to GitHub, and pull your changes down to your live Web server. This allows you to work and experiment without breaking your live Web site. Pretty cool, huh?
295225

296226

297227
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!
228+
245 Bytes
Loading
42.2 KB
Loading
-87.5 KB
Binary file not shown.

en/deploy/signup_pythonanywhere.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11

2-
Next, it's time to sign up for a free "Beginner" account on PythonAnywhere.
2+
Sign up for a free "Beginner" account on PythonAnywhere:
33

44
* [www.pythonanywhere.com](https://www.pythonanywhere.com/)
55

66

77
> **Note** When choosing your username here, bear in mind that your blog's URL will take the form `yourusername.pythonanywhere.com`, so choose either your own nickname or a name for what your blog is all about.
8+
9+
## Creating a PythonAnywhere API token
10+
11+
This is something you only need to do once. When you've signed up for PythonAnywhere, you'll be taken to your dashboard. Find the link near the top right to your "Accounts" page, then select the tab named "API token", and hit the button that says "Create new API token".
12+
13+
<img src="images/pythonanywhere_create_api_token.png" alt="The API token tab on the Accounts page" />
14+

en/django_forms/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,11 +415,14 @@ $ git push
415415

416416
{% filename %}command-line{% endfilename %}
417417
```
418-
$ cd my-first-blog
418+
$ cd ~/<your-pythonanywhere-username>.pythonanywhere.com
419419
$ git pull
420420
[...]
421421
```
422422

423+
(Remember to substitute `<your-pythonanywhere-username>` with your actual PythonAnywhere username, without the angle-brackets).
424+
425+
423426
* Finally, hop on over to the [Web tab](https://www.pythonanywhere.com/web_app_setup/) and hit **Reload**.
424427

425428

en/django_models/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ from django.utils import timezone
126126

127127

128128
class Post(models.Model):
129-
author = models.ForeignKey('auth.User',on_delete=models.CASCADE)
129+
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
130130
title = models.CharField(max_length=200)
131131
text = models.TextField()
132132
created_date = models.DateTimeField(

0 commit comments

Comments
 (0)