Найти - Пользователи
Полная версия: Как реализовать сложный запрос для Django Paginator ?
Начало » Django » Как реализовать сложный запрос для Django Paginator ?
1 2 3
FishHook
select_related()
Returns a QuerySet that will automatically “follow” foreign-key relationships, selecting that additional related-object data when it executes its query. This is a performance booster which results in (sometimes much) larger queries but means later use of foreign-key relationships won't require database queries.

The following examples illustrate the difference between plain lookups and select_related() lookups. Here's standard lookup:

# Hits the database.
e = Entry.objects.get(id=5)

# Hits the database again to get the related Blog object.
b = e.blog
And here's select_related lookup:

# Hits the database.
e = Entry.objects.select_related().get(id=5)

# Doesn't hit the database, because e.blog has been prepopulated
# in the previous query.
b = e.blog
Saturn
FishHook Спасибо,
Вот это мне как раз и нужно, видать я не внимательно читал документацию.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB