Better HN
topnewbestaskshowjobs
Log inSign up

gedazz

8 karma · joined Feb 17, 2012 (14y ago) · 4 submissions

Submissions

comment 5y ago · link · parent

What does CoC stand for?

comment 5y ago · link · parent

I have never encountered this issue in Django. Perhaps your post lacks some context. Is `friends` a custom method/property? Asking because I'm used to seeing attributes like `friends_set`.

The only scenario I see where your example would need `prefetch_related` is if your snippet looked something like this:

    {% for user in all_users %}
        <ul>
        {% for friend in user.friends.all %}
        <li>{{ friend.name }}</li>
        {% endfor %}
        </ul>
    {% endfor %}
To avoid the classic N+1 query problem, all_users must be loaded like so:

    User.objects.all().prefetch_related("friends")
If you're writing verbose expressions such as this in Django:

    User.objects.filter(pk=<pk>).prefetch_related("friends").first()
You must be doing something wrong.

comment 6y ago · link · parent

Besides pushing articles I want to read later to Pocket I tend to use the principle "if I cannot remember the name/address of the website, I do not need to bookmark or visit it". Browsers nowadays are excellent at autocompletion which kind of supersedes bookmarks.

comment 12y ago · link · parent

There are more on their Youtube channel https://www.youtube.com/channel/UCFDHJGm0IxH9uwcIHfR72yg/vid...