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
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,7 +245,7 @@ You can also go to the "Files" page and navigate around using PythonAnywhere's b
245
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
246
247
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/2.2/howto/deployment/checklist/) for some tips on securing your site.
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.
Copy file name to clipboardExpand all lines: en/django_admin/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,6 @@ Make sure that at least two or three posts (but not all) have the publish date s
52
52
53
53

54
54
55
-
If you want to know more about Django admin, you should check Django's documentation: https://docs.djangoproject.com/en/2.2/ref/contrib/admin/
55
+
If you want to know more about Django admin, you should check Django's documentation: https://docs.djangoproject.com/en/3.2/ref/contrib/admin/
56
56
57
57
This is probably a good moment to grab a coffee (or tea) or something to eat to re-energize yourself. You created your first Django model – you deserve a little break!
Copy file name to clipboardExpand all lines: en/django_models/README.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -92,6 +92,7 @@ djangogirls
92
92
├── db.sqlite3
93
93
├── manage.py
94
94
├── mysite
95
+
│ ├── asgi.py
95
96
│ ├── __init__.py
96
97
│ ├── settings.py
97
98
│ ├── urls.py
@@ -102,7 +103,7 @@ djangogirls
102
103
103
104
```
104
105
105
-
After creating an application, we also need to tell Django that it should use it. We do that in the file `mysite/settings.py` -- open it in your code editor. We need to find `INSTALLED_APPS` and add a line containing `'blog.apps.BlogConfig',` just above `]`. So the final product should look like this:
106
+
After creating an application, we also need to tell Django that it should use it. We do that in the file `mysite/settings.py` -- open it in your code editor. We need to find `INSTALLED_APPS` and add a line containing `'blog',` just above `]`. So the final product should look like this:
106
107
107
108
{% filename %}mysite/settings.py{% endfilename %}
108
109
```python
@@ -113,7 +114,7 @@ INSTALLED_APPS = [
113
114
'django.contrib.sessions',
114
115
'django.contrib.messages',
115
116
'django.contrib.staticfiles',
116
-
'blog.apps.BlogConfig',
117
+
'blog',
117
118
]
118
119
```
119
120
@@ -163,7 +164,7 @@ Now we define the properties we were talking about: `title`, `text`, `created_da
163
164
-`models.DateTimeField` – this is a date and time.
164
165
-`models.ForeignKey` – this is a link to another model.
165
166
166
-
We will not explain every bit of code here since it would take too much time. You should take a look at Django's documentation if you want to know more about Model fields and how to define things other than those described above (https://docs.djangoproject.com/en/2.2/ref/models/fields/#field-types).
167
+
We will not explain every bit of code here since it would take too much time. You should take a look at Django's documentation if you want to know more about Model fields and how to define things other than those described above (https://docs.djangoproject.com/en/3.2/ref/models/fields/#field-types).
167
168
168
169
What about `def publish(self):`? This is exactly the `publish` method we were talking about before. `def` means that this is a function/method and `publish` is the name of the method. You can change the name of the method if you want. The naming rule is that we use lowercase and underscores instead of spaces. For example, a method that calculates average price could be called `calculate_average_price`.
169
170
@@ -181,8 +182,8 @@ The last step here is to add our new model to our database. First we have to mak
181
182
```
182
183
(myvenv) ~/djangogirls$ python manage.py makemigrations blog
183
184
Migrations for 'blog':
184
-
blog/migrations/0001_initial.py:
185
-
- Create model Post
185
+
blog/migrations/0001_initial.py
186
+
- Create model Post
186
187
```
187
188
188
189
**Note:** Remember to save the files you edit. Otherwise, your computer will execute the previous version which might give you unexpected error messages.
Copy file name to clipboardExpand all lines: en/django_start_project/README.md
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,7 @@ The `(myvenv) C:\Users\Name\djangogirls>` part shown here is just example of the
53
53
djangogirls
54
54
├── manage.py
55
55
├── mysite
56
+
│ ├── asgi.py
56
57
│ ├── __init__.py
57
58
│ ├── settings.py
58
59
│ ├── urls.py
@@ -87,7 +88,7 @@ In `settings.py`, find the line that contains `TIME_ZONE` and modify it to choos
87
88
TIME_ZONE='Europe/Berlin'
88
89
```
89
90
90
-
A language code consist of the language, e.g. `en` for English or `de` for German, and the country code, e.g. `de` for Germany or `ch` for Switzerland. If English is not your native language, you can add this to change the default buttons and notifications from Django to be in your language. So you would have "Cancel" button translated into the language you defined here. [Django comes with a lot of prepared translations](https://docs.djangoproject.com/en/2.2/ref/settings/#language-code).
91
+
A language code consist of the language, e.g. `en` for English or `de` for German, and the country code, e.g. `de` for Germany or `ch` for Switzerland. If English is not your native language, you can add this to change the default buttons and notifications from Django to be in your language. So you would have "Cancel" button translated into the language you defined here. [Django comes with a lot of prepared translations](https://docs.djangoproject.com/en/3.2/ref/settings/#language-code).
91
92
92
93
If you want a different language, change the language code by changing the following line:
93
94
@@ -102,7 +103,7 @@ We'll also need to add a path for static files. (We'll find out all about static
102
103
{% filename %}mysite/settings.py{% endfilename %}
103
104
```python
104
105
STATIC_URL='/static/'
105
-
STATIC_ROOT=os.path.join(BASE_DIR, 'static')
106
+
STATIC_ROOT=BASE_DIR/'static'
106
107
```
107
108
108
109
When `DEBUG` is `True` and `ALLOWED_HOSTS` is empty, the host is validated against `['localhost', '127.0.0.1', '[::1]']`. This won't
Copy file name to clipboardExpand all lines: en/django_urls/README.md
+15-2Lines changed: 15 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,10 +93,23 @@ The last part, `name='post_list'`, is the name of the URL that will be used to i
93
93
94
94
If you try to visit http://127.0.0.1:8000/ now, then you'll find some sort of 'web page not available' message. This is because the server (remember typing `runserver`?) is no longer running. Take a look at your server console window to find out why.
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
101
+
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
102
+
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
103
+
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
104
+
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
105
+
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
106
+
File "/Users/ola/djangogirls/blog/urls.py", line 5, in <module>
107
+
path('', views.post_list, name='post_list'),
108
+
AttributeError: module 'blog.views' has no attribute 'post_list'
109
+
```
97
110
98
111
Your console is showing an error, but don't worry – it's actually pretty useful: It's telling you that there is __no attribute 'post_list'__. That's the name of the *view* that Django is trying to find and use, but we haven't created it yet. At this stage, your `/admin/` will also not work. No worries – we will get there.
99
112
If you see a different error message, try restarting your web server. To do that, in the console window that is running the web server, stop it by pressing Ctrl+C (the Control and C keys together). On Windows, you might have to press Ctrl+Break. Then you need to restart the web server by running a `python manage.py runserver` command.
100
113
101
114
102
-
> If you want to know more about Django URLconfs, look at the official documentation: https://docs.djangoproject.com/en/2.2/topics/http/urls/
115
+
> If you want to know more about Django URLconfs, look at the official documentation: https://docs.djangoproject.com/en/3.2/topics/http/urls/
Copy file name to clipboardExpand all lines: en/django_views/README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,4 +39,4 @@ Another error! Read what's going on now:
39
39
40
40
This shows that the server is running again, at least, but it still doesn't look right, does it? Don't worry, it's just an error page, nothing to be scared of! Just like the error messages in the console, these are actually pretty useful. You can read that the *TemplateDoesNotExist*. Let's fix this bug and create a template in the next chapter!
41
41
42
-
> Learn more about Django views by reading the official documentation: https://docs.djangoproject.com/en/2.2/topics/http/views/
42
+
> Learn more about Django views by reading the official documentation: https://docs.djangoproject.com/en/3.2/topics/http/views/
0 commit comments