On Apr 6, 6:38 am, codingJoe <[email protected]> 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 [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-users?hl=en
-~----------~----~----~----~------~----~------~--~---