If you are trying to construct a "base" template for several views you could also use the {% if %} tags, and only show the relevant parts of the page. For example, if you wanted to display a table, but the number om columns would vary, this would enable you to only display the needed columns.
On a side note, you shouldn't be doing the logic in the template, and when needed pull in different stuff, do operations ect. Instead you should use your views for that, and keep the template for presentation. That's the way django is built and it would also make it a lot easier on your self and others if you keep logic and presentation separate. ~Jakob On 6 Apr., 09:59, Daniel Roseman <roseman.dan...@googlemail.com> wrote: > On Apr 6, 6:38 am, codingJoe <tmont...@mac.com> wrote: > > > > > Up front, I'm not the most elegant coder, so please forgive. > > > I have a page that is produced using django templates. I used the > > templates to do the header and footer, but now I'm down into the body > > of the page. Using the data from my template, I am able to fill the > > first cell. > > > Is is possible to have the template do a request/response for other > > data? Or do I have to pass it all in when I build the page. Analogy > > would be an <img src="\myMethod" >, but I don't want an image just > > some text-based table data. Or, a SharePoint WebPart that fits in a > > table, but does its own thing. > > > {% block body %} > > I am well within my body block... > > > <table> > > <tr> > > <td>{{MyModel.A}}, {{MyModel.B}} </td> <!-- This works fine --> > > <td> May Exist, May Not... Would like to pull data from another > > request/response </td> > > <td> May Exist, May Not... Would like to pull data from another > > request/response <td> > > <table> > > {% end block %} > > > 1. If this is possible, how do I do it? Simple example please. > > > 2. If this is poor coding, how is what I'm trying to do best > > accomplished? > > You could do this via AJAX - ie writing some Javascript to request the > content and inject it into the page - if you really wanted. But I > can't understand why on earth you'd want to. If you want to show a > list of model instances, get a queryset in the view and iterate > through it in the template. Making several request/responses to render > a simple page will massively increase the load on your server and the > time it takes for the user to see the finished page. > > Can you explain in a bit more detail what you're trying to do, and why > it couldn't be achieved by simply passing a queryset into the template > and using the {% for %} tag? > -- > DR. --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---