Coder Social home page Coder Social logo

two-scoops-of-django-1.5's People

Contributors

pydanny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

pombredanne

two-scoops-of-django-1.5's Issues

Example 11.7 csrftoken is not defined

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's list of issues

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.

Issues per chapter

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?

Issue with example 16.9

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.

Issue in the EPUB examples, not following the same order than the PDF and some don't appear

Noticed there's is differences between the PDF and the EPUB... for example chapter 9, to be more accurate:

  • 9.6 Pattern 5: Reusable Search Mixin View

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:

pdf

-EPUB screenshot:

epub

.

6.2.4 When to Use Null and Blank

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.