> Attempting to do a method call {% views.get_stuff %} just results in a 'bad
> tag' error.

Right, because there is no tag with the name 'views.get_stuff'.

> Doing it like a variable {{ views.get_stuff }} just seems to be ignored.

Not ignored, but it probably fails which the template engine treats as
an empty string.

Did you try passing 'views' as a context object to the template?
This is a little unusual, but I just tested it and it does work:

import views
return render_to_response('now.html', RequestContext(request,  {
                'views':       views,
                }} )

And now {{views.something}} will call the function 'something'.

Thinking about importing a module into itself makes my brain hurt. 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.

Of course, all of this is kinda twisted from a Django point of view,
and, since you can't pass any parameters to these functions, that
means you are now (probably) using globals, which your Mom should have
taught you are Not Nice.

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.

If you need to do all kinds of mid-template computing (which Django
templates are deliberately designed to discourage), consider using a
different template package altogether. See 
http://www.djangosnippets.org/snippets/97/
for an example on how this can be done.

  HTH,
  Peter
--~--~---------~--~----~------------~-------~--~----~
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