Peter Rowell wrote:
> It
> would probably be better (for any number of reasons) if you put all of
> these types of routines in a utils.py module and import/pass that.
> E.g.
> 
> import utils
> return render_to_response('now.html', RequestContext(request,  {
>                 'utils': utils,
>                 }} )
> 
> Then you can do {{utils.something}} and it will fill in with the
> output of the function.

Thanks. I can see how this would work. But it appears the return of every 
'view' method would have to be cluttered with this and that's sort-of what I'm 
specifically trying to avoid.

> I recommend rethinking how data is passed into and used in your
> templates. Consider creating your own content processor. Or maybe some
> custom template tags and/or filters.  See
> http://www.djangoproject.com/documentation/templates_python/ and
> djangobook.com for much more on these options.

I've been reading up on this option and it may be what I'm looking for. But it 
seems surprising that such an "advanced" feature would have to be called upon 
to do something that seems, to me, so common. But there's gotta be something 
I'm missing. (See below)

> If you need to do all kinds of mid-template computing (which Django
> templates are deliberately designed to discourage)

Could you elaborate please?

My web pages won't be so different, I think, than many others. Each page will 
have "main content" and "other stuff". The "other stuff" is not related to 
"main stuff" and therefore "main stuff" shouldn't know anything about them. 
But lots of the "other stuff" need to be created dynamically so I have to 
somehow invoke a method that does the job.

Is this what you're referring to as mid-template computing? What's the correct 
way?

I'm a noob and I've figured out using urls.py how you give control to a 
routine to produce the "main stuff" for a page, but I can't figure out how to 
invoke some other routine to create the "other stuff".

Clear as mud?

Thanks for any help,
Michael



--~--~---------~--~----~------------~-------~--~----~
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