twoscoops / two-scoops-of-django-1.5 Goto Github PK
View Code? Open in Web Editor NEWTracking bugs, errors, and corrections to Two Scoops of Django
Home Page: https://django.2scoops.org
Tracking bugs, errors, and corrections to Two Scoops of Django
Home Page: https://django.2scoops.org
Csrftoken is not defined but reading the link you provide (https://docs.djangoproject.com/en/1.5/ref/contrib/csrf/) is possible to understand how to fix it.
Acquiring the token is straightforward:
// using jQuery
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
The above code could be simplified by using the jQuery cookie plugin to replace getCookie:
var csrftoken = $.cookie('csrftoken');
Rico Moorman sent me these issues. Normally we don't accept more than one item per issue, but this as this was an email, I make the exception.
note: These won't be factored into 2SoD 1.5, but will be considered in the forthcoming 2SoD 1.6.
9.1
- consider wrapping these more general point(s) into the introduction (9)
- also feels a little like duplicating the points of the introduction
10.1.1
- disabling CSRF protection is distinct from (not) using POST
- "dangling" subsection feels misplaced too (other places within the book also have those dangling subsections)
- should probably be 10.x
11.3.1
- Last two sentences contain the same information/are redundant
12
- "keep business logic IN the Python side of things" should probably contain "on" instead of "in"
12.2.2
- typo in example. "extends base_profile.html" should be "extends base_profiles.html"; mind the extra "s"
12.3.1
- example 12.5 contains the calculation of "delta" twice
12.5, 12.6
- could possibly be wrapped together as something like "know how to use the template inheritance"
12.7.1
- it feels strange to read "python code" here … "templates" could be more appropriate as they are for markup anyway; and the separation of markup and style is what is covered
12.7.2
- possibly apply "never write just {% endblock %}" to the book
- apply the underscore include convention to the "message" template defined in example 8.8
13.2.4
- "Anything that causes a read/write of data might be better placed in a model or object method" where does the object come from … what is it? what object?
16.1
- little strange maybe to have one "dangling" subsection here… (16.1.1) combine it with main point?
16.2.3
- example 16.7 uses old format style with %
- the AUTH_USER_MODEL setting is referred with "like the first option" but this happened in option #2
- in option #2 the comment with filename is missing for settings/base.py
18.2
- within the TIP box … "When you don't prefix your test modules this way, django-discover-runner will attempt to evaluate all modules, including your _settings_ files"; I guess this should be "test files" instead.
18.7.1
- TIP about sqlite. "we've yet to catch problems caused by SQLite3's loose field typing"; the point of tests is to discover problems which could probably also occur on live and especially using a non-strict db could "hide" problems until code hits production
so maybe this should be worded differently or I got it wrong
18.7.3
- in the example … wouldnt "$SITE_URL*" expand to just an asterisk?
22.3.5
- in the example … ".get_context_data(**kwargs)" would be more consistent as ".get_context_data(*args, **kwargs)"
- also in the example … old format syntax
23
- Suddenly the summary is missing .. all other chapters had one
Appendix A
- mentioned packages don't flawlessly resemble things found in book … e.g. Logging, loggly is missing
Probably Chapter 26 and Appendix C could be joined?
In your book on page 164 in the TwoScoopsUserChangeForm class, you have:
password = ReadOnlyPasswordHashField()
class Meta:
model = TwoScoopsUser
def clean_password(self):
# Regardless of what the user provides, return the
# initial value. This is done here, rather than on
# the field, because the field does not have access
# to the initial value
return self.initial["password”]
If I make no changes to my custom user model through the admin and click save, a log history record is still created that says "Changed password." The only way I can get it to stop is by commenting out the line password = ReadOnlyPasswordHashField()
, but then the field can be changed. Do you have any suggestions on why this might be happening or how I can stop it? Thank you.
Noticed there's is differences between the PDF and the EPUB... for example chapter 9, to be more accurate:
On the PDF the first example is 9.13 on the EPUB is 9.12 because chapters before the EPUB never show up some examples and continue on the EPUB the example 9.13 is totally empty.
I attach a couple of images to illustrate what I mean:
-PDF screenshot:
-EPUB screenshot:
.
In the subsections starting with:
"When using IntegerField, FloatField, DecimalField, etc"
Use null is repeated for both bullet items when you meant "use blank" for the second bullet item.
For example 5.9 on page 36, setx
does not appear to work for this type of environmental variable (in Win 8.1). Also, there need to be quotation marks.
I was able to get it to work using this syntax:
set "SOME_SECRET_KEY=1c3-cr3am-15-yummy"
in the activate.bat for my virtual environment.
In Example 5.8 (page 35 of the 1.5 Book) the secret key needs a single quote before and after the key value in order to work correctly in the virtualenv activate file.
Without the single quotes you get an error when activating the environment. I'm not sure if this always happens, the left parenthesis in my key value was unexpected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.