Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions django_admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ Let's open the `blog/admin.py` file and replace its content with this:

As you can see, we import (include) the Post model defined in the previous chapter. To make our model visible on the admin page, we need to register the model with `admin.site.register(Post)`.

OK, time to look at our Post model. Remember to run `python manage.py runserver` in the console to run the web server. Go to the browser and type the address:

http://127.0.0.1:8000/admin/

You will see a login page like this:
OK, time to look at our Post model. Remember to run `python manage.py runserver` in the console to run the web server. Go to the browser and type the address http://127.0.0.1:8000/admin/ You will see a login page like this:

![Login page](images/login_page2.png)

Expand Down
6 changes: 3 additions & 3 deletions django_forms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ After adding the line, your html file should now look like this:
</body>
</html>

After saving and refreshing the page `http://127.0.0.1:8000` you will obviously see a familiar `NoReverseMatch` error, right?
After saving and refreshing the page http://127.0.0.1:8000 you will obviously see a familiar `NoReverseMatch` error, right?

## URL

Expand Down Expand Up @@ -198,7 +198,7 @@ Ok, we talked a lot, but we probably want to see what the whole *view* looks lik
form = PostForm()
return render(request, 'blog/post_edit.html', {'form': form})

Let's see if it works. Go to the page `http://127.0.0.1:8000/post/new/`, add a `title` and `text`, save it... and voilà! The new blog post is added and we are redirected to `post_detail` page!
Let's see if it works. Go to the page http://127.0.0.1:8000/post/new/, add a `title` and `text`, save it... and voilà! The new blog post is added and we are redirected to `post_detail` page!

You problably have noticed that we are not setting publish date at all. We will introduce a _publish button_ in __Django Girls Tutorial: Extensions__.

Expand All @@ -214,7 +214,7 @@ Try to save the form without `title` and `text`. Guess, what will happen!

Django is taking care of validating that all the fields in our form are correct. Isn't it awesome?

> As we have recently used the Django admin interface the system currently thinks we are logged in. There are a few situations that could lead to us being logged out (closing the browser, restarting the DB etc.). If you find that you are getting errors creating a post referring to a lack of a logged in user, head to the admin page `http://127.0.0.1:8000/admin` and log in again. This will fix the issue temporarily. There is a permanent fix awaiting you in the __Homework: add security to your website!__ chapter after the main tutorial.
> As we have recently used the Django admin interface the system currently thinks we are logged in. There are a few situations that could lead to us being logged out (closing the browser, restarting the DB etc.). If you find that you are getting errors creating a post referring to a lack of a logged in user, head to the admin page http://127.0.0.1:8000/admin and log in again. This will fix the issue temporarily. There is a permanent fix awaiting you in the __Homework: add security to your website!__ chapter after the main tutorial.

![Logged in error](images/post_create_error.png)

Expand Down
6 changes: 3 additions & 3 deletions django_urls/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ imagine you have a website with the address like that: `http://www.mysite.com/po

## Your first Django url!

Time to create our first URL! We want http://127.0.0.1:8000/ to be a homepage of our blog and display a list of posts.
Time to create our first URL! We want 'http://127.0.0.1:8000/' to be a homepage of our blog and display a list of posts.

We also want to keep the `mysite/urls.py` file clean, so we will import urls from our `blog` application to the main `mysite/urls.py` file.

Expand All @@ -60,7 +60,7 @@ Your `mysite/urls.py` file should now look like this:
url(r'', include('blog.urls')),
)

Django will now redirect everything that comes into `http://127.0.0.1:8000/` to `blog.urls` and look for further instructions there.
Django will now redirect everything that comes into 'http://127.0.0.1:8000/' to `blog.urls` and look for further instructions there.

## blog.urls

Expand All @@ -81,7 +81,7 @@ As you can see, we're now assigning a `view` called `post_list` to `^$` URL. But
- `^` in regex means "the beginning"; from this sign we can start looking for our pattern
- `$` matches only "the end" of the string, which means that we will finish looking for our pattern here

If you put these two signs together, it looks like we're looking for an empty string! And that's correct, because in Django url resolvers, `http://127.0.0.1:8000/` is not a part of URL. This pattern will show Django that `views.post_list` is the right place to go if someone enters your website at the `http://127.0.0.1:8000/` address.
If you put these two signs together, it looks like we're looking for an empty string! And that's correct, because in Django url resolvers, 'http://127.0.0.1:8000/' is not a part of URL. This pattern will show Django that `views.post_list` is the right place to go if someone enters your website at the 'http://127.0.0.1:8000/' address.

Everything all right? Open http://127.0.0.1:8000/ in your browser to see the result.

Expand Down
16 changes: 3 additions & 13 deletions extend_your_application/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ Time to explain the mysterious `{% url 'blog.views.post_detail' pk=post.pk %}`.

`blog.views.post_detail` is a path to a `post_detail` *view* we want to create. Please note: `blog` is the name of our application (the directory `blog`), `views` is from the name of the `views.py` file and the last bit - `post_detail` - is the name of the *view*.

Now when we go to:

http://127.0.0.1:8000/

we will have an error (as expected, since we don't have a URL or a *view* for `post_detail`). It will look like this:
Now when we go to: http://127.0.0.1:8000/ we will have an error (as expected, since we don't have a URL or a *view* for `post_detail`). It will look like this:

![NoReverseMatch error](images/no_reverse_match2.png)

Expand Down Expand Up @@ -67,11 +63,7 @@ That means if you enter `http://127.0.0.1:8000/post/5/` into your browser, Djang

`pk` is shortcut for `primary key`. This name is often used in Django projects. But you can name your variable as you like (remember: lowercase and `_` instead of whitespaces!). For example instead of `(?P<pk>[0-9]+)` we could have variable `post_id`, so this bit would look like: `(?P<post_id>[0-9]+)`.

Ok! Let's refresh the page:

http://127.0.0.1:8000/

Boom! Yet another error! As expected!
Ok! Let's refresh the page: http://127.0.0.1:8000/ Boom! Yet another error! As expected!

![AttributeError](images/attribute_error2.png)

Expand Down Expand Up @@ -107,9 +99,7 @@ Near other `from` lines. And at the end of the file we will add our *view*:
post = get_object_or_404(Post, pk=pk)
return render(request, 'blog/post_detail.html', {'post': post})

Yes. It is time to refresh the page:

http://127.0.0.1:8000/
Yes. It is time to refresh the page: http://127.0.0.1:8000/

![Post list view](images/post_list2.png)

Expand Down