diff --git a/manuscript/chapter10-cookies.md b/manuscript/chapter10-cookies.md index 40b393f..3cc01de 100644 --- a/manuscript/chapter10-cookies.md +++ b/manuscript/chapter10-cookies.md @@ -279,8 +279,8 @@ If you need more secure cookies, then use session based cookies. 1. Firstly, ensure that the `MIDDLEWARE_CLASSES` list in your Django project's `settings.py` module contains `django.contrib.sessions.middleware.SessionMiddleware`. If it doesn't, add it to the list. 2. Configure your session backend `SESSION_ENGINE`. See the [official Django Documentation on Sessions](https://docs.djangoproject.com/en/1.9/topics/http/sessions/) for the various backend configurations. -3. Check to see if the cookie exists via `requests.sessions.get()`. -4. Update or set the cookie via the session dictionary, `requests.session['']`. +3. Check to see if the cookie exists via `request.session.get()`. +4. Update or set the cookie via the session dictionary, `request.session['']`. X> ### Exercises X> @@ -289,4 +289,4 @@ X> X> - Check that your cookies are server side. Clear the browser's cache and cookies, then check to make sure you can't see the `last_visit` and `visits` variables in the browser. Note you will still see the `sessionid` cookie. Django uses this cookie to look up the session in the database where it stores all the server side cookies about that session. X> - Update the *About* page view and template telling the visitors how many times they have visited the site. Remember to call the `visitor_cookie_handler()` before you attempt to get the `visits` cookie from the `request.session` dictionary, otherwise if the cookie is not set it will raise an error. -[^1]: The latest version of the HTTP standard HTTP 1.1 actually supports the ability for multiple requests to be sent in one TCP network connection. This provides huge improvements in performance, especially over high-latency network connections (such as via a traditional dial-up modem and satellite). This is referred to as *HTTP pipelining*, and you can read more about this technique on [Wikipedia](http://en.wikipedia.org/wiki/HTTP_pipelining). \ No newline at end of file +[^1]: The latest version of the HTTP standard HTTP 1.1 actually supports the ability for multiple requests to be sent in one TCP network connection. This provides huge improvements in performance, especially over high-latency network connections (such as via a traditional dial-up modem and satellite). This is referred to as *HTTP pipelining*, and you can read more about this technique on [Wikipedia](http://en.wikipedia.org/wiki/HTTP_pipelining). diff --git a/manuscript/chapter18-ajax.md b/manuscript/chapter18-ajax.md index 0174dbb..a655029 100644 --- a/manuscript/chapter18-ajax.md +++ b/manuscript/chapter18-ajax.md @@ -36,7 +36,7 @@ To let users "like" certain categories, undertake the following workflow. - In the `category.html` template: - Add in a "Like" button with `id="like"`. - - Add in a template tag to display the number of likes: `{{% category.likes %}}` + - Add in a template tag to display the number of likes: `{{ category.likes }}` - Place this inside a div with `id="like_count"`, i.e. `
{{ category.likes }}
` - This sets up the template to capture likes and to display likes for the category. - Note, since the `category()` view passes a reference to the category object, we can use that to access the number of likes, with `{{ category.likes }}` in the template