Prefetch root page in Site.find_for_request. Thanks to Yannick Chabbert for the suggestion!

This commit is contained in:
Matt Westcott 2016-04-12 12:48:56 +01:00
parent 2e970f88ea
commit 1d2ec402fa
2 changed files with 6 additions and 1 deletions

View file

@ -121,6 +121,7 @@ Contributors
* Danielle Madeley
* Janneke Janssen
* Roel Bruggink
* Yannick Chabbert
Translators
===========

View file

@ -147,7 +147,11 @@ class Site(models.Model):
default=MATCH_HOSTNAME,
output_field=IntegerField(),
)).filter(Q(hostname=hostname) | Q(is_default_site=True)).order_by('match'))
)).filter(Q(hostname=hostname) | Q(is_default_site=True)).order_by(
'match'
).select_related(
'root_page'
))
if sites:
# if theres a unique match or hostname (with port or default) match