Does Django have any thread safety issues

The German Python forum

Hello my dear fellow forums.

I recently started learning Python and Django and it's been going pretty well so far. The documentaries and forum entries with frequent errors / questions help a lot.

However, sometimes I just have little problems because I just don't have many years of programming experience. I just got to such a hangover and just don't understand where my brain is exactly.

First my code: (is from an O'Reilly tutorial)

Code: Select all

Code: Select all

Extract from

Code: Select all

Extract from list.html:

Code: Select all

What I don't understand now are two things:

1.a. Why the "detour" via the variable "context"?
Delivers books = Book.objects.exclude (date_reviewed__isnull = True) not already a ruse with all the books?
I can write in the Django Shell:

books = Book.objects.exclude (date_reviewed__isnull = True) and then with
books [0] .title, books [1] .title iterate etc through

1.b. And even if I do it via "context":

Why is a simple one enough context = {"books": books} ?

Shouldn't I have to iterate through once for every single book? So something like for book in books? I always have to do it that way?
Or to put it another way, what is the advantage of having a dictionary that looks like this:
"books": infos_zu_buch1, Infos_zu_buch2, ...
instead of having a ruse that looks like this:
infos_zu_buch1, Infos_zu_buch2, ...

What is the point of having a dictionary here instead of a list?
That's what the detour via context brings, right?

2. Where exactly does the term "books" come from in {{books.count}}?

If the dictionary "context" is passed, then it should be context ["books"]. Count ???

These may be the most embarrassing beginners mistakes for you, but I've been thinking about it for a long time and I just don't understand it.

Perhaps one of you can untie the knot (s).

Thanks in advance!!