Hey Luke,

On Fri, 2006-05-19 at 13:15 +0100, Luke Plant wrote:
> Malcolm,
> 
> I noticed this addition to the docs in django-updates:
> 
> +  Note that QuerySets are not callable, so
> +  if you want to pass in a QuerySet in ``extra_context`` and have it
> +  evaluated at render time, you need to wrap it in a function (that
> +  returns the QuerySet).
> 
> I think this confuses the issue slightly - the fundamental problem is 
> that QuerySets cache the data they get back from the db when you 
> evaluate them.  Could I suggest something like this instead:
> 
> Note that QuerySets retrieve and cache their data when they are first 
> evaluated, so if you want to pass in a QuerySet in ``extra_context`` 
> that is always fresh you need to wrap it in a function or lambda that 
> returns the QuerySet.

Thanks heaps for the feedback. Agree fully that my text is confusing and
I would like to have something much shorter there. Your explanation is
correct, but also sliding past the issue a little, isn't it? The reason
I attempted to clairfy this is because a couple of people were confused
about the "liveness" or otherwise of extra_context members. Maybe
singling out QuerySets for special attention actually confuses things
more than helps.

Should we just omit that "Note..." sentence altogether? So it becomes:

        * ``extra_context``: A dictionary of values to add to the
        template context. By default, this is an empty dictionary. If a
        value in the dictionary is callable, the generic view will call
        it just before rendering the template. If it is not callable, it
        will be evaluated once, at import time.

(I'm not really thrilled about "at import time" there, either, now that
I reread it. What a lame way to try and nail down the evaluation time.
I'll work on that.) Is it clearer if we leave it out altogether?

Trying to put in a repetitive long explanation about extra_context for
every function looks poor, I think. Maybe we should just suck out an
explanation of extra_context to the top of the document and explain
QuerySet evaluation up there.

If you don't have any really strong feels that either of these are an
improvement, I think we should just commit your change, since it at
least addresses the main area people are going to mess this up. But I
wouldn't mind if we could do better still. I'll think about it
overnight, but I'm not going to mind if you just dive in and edit it.
I'm just tweaking the docs as things come up: I'm pretty thick-skinned
about being edited.

Best wishes,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to