-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Observed Behavior
Calculating and displaying the copyright notice for a page makes repeated queries to the SiteVars table, both in the template tags and in the models (MediaObject and AbstractOpenGraph).
The get_template_names and get_context_data methods of the views also make repeated SiteVar queries to look up template names.
In list views, the pagination methods make separate queries for site pagination defaults.
Expected Behavior
SiteVars should be cached and the table should be accessed no more than once per request.
Probably the "get_value" should be either removed entirely to prevent temptation, or modified so that it makes no database queries but only accesses the cached values.
It might be convenient if Unfortunately that would interfere with Django's default queryset slicing. Best not to change Django's default behavior, that would be confusing for users.site.vars was subscriptable, allowing you to access a site var as site.vars["base_template"]. Again, this should access the cache and not produce a database query.