Or may be a custom template tag for common stuff.

On Jul 2, 5:59 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> Brrr... Try to use context 
> processorshttp://www.djangoproject.com/documentation/templates_python/#subclass...
>
> On Jul 2, 5:43 pm, Mario <[EMAIL PROTECTED]> wrote:
>
> > I understand. Global context = {} was bad solution...
> > views,py:
> > context = {
> >     'hot_news': News.objects.filter(hot=True).order_by('-created')[0],
> >     'last_radio_message': VisualRadio.objects.all().order_by('-
> > created')[0],
> >     'last_totals': Totals.objects.all().order_by('-created')[0],
> >     'last_poll': Poll.objects.all().order_by('-created')[0],
>
> > }
>
> > def index(request):
> >     context["hot_news"] = News.objects.filter(hot=True).order_by('-
> > created')[0]
> >     context["news_list"] = News.objects.filter(hot=False).order_by('-
> > created')[:5]
> >     return render_to_response('index.html', context)
>
> > Please, help me to write good code. I don't want repeat code in every
> > view...
>
> > On Jul 2, 3:42 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
>
> > > On Wed, Jul 2, 2008 at 7:09 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> > > > Client-side caching. Use the `never_cache` decorator
>
> > > No, that's not it at all.
>
> > > > On Jul 2, 3:43 pm, Mario <[EMAIL PROTECTED]> wrote:
> > > >> I look at sql log - django didn't query that, but always query lists,
> > > >> for example:
> > > >>     context["news_list"] = News.objects.filter(hot=False).order_by('-
> > > >> created')[:5]
>
> > > >> what is this? mod_python? caching?
>
> > > When launched, mod_python loads your code once and only once for each
> > > server process, and holds it in memory afterward. This is a trade-off
> > > made or efficiency, because reloading the code on every request would
> > > significantly slow the server. As a result, whenever you make a change
> > > to code that runs under mod_python, you must also restart the web
> > > server.
>
> > > In addition, any variable assigned at the module global level will
> > > only be evaluated once, which means that any top-level variable
> > > declaration which does a database query will only evaluate once per
> > > server process, rather than appearing to refresh on each request.
>
> > > --
> > > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > > correct."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to