0👍
Loading a template from a dedicated template file is in almost any case cleaner. A long python string with HTML in it is not very readable.
Of course you could also send your books via add_data(data,callback_function)
and write a javascript callback function that populates the list which would be the Dajax way of doing what Thomas Orozco proposed.
But judging from the pagination example rendering a template file and sending it to innerHTML
is ‘the right way’.
1👍
I never heard about dajax
before (but it looks like the project has gone sightly inactive as the latest commit is ~10 months old), so I’ll offer advice that is not directly related to dajax
.
Basically, what you need to do is to display a list that is retrieved using AJAX. That’s pretty trivial using the following tools:
- jQuery (or another JS framework)
- JSON
What you need to do is:
- Configure one of your views so that it returns a list of books (look here for the documentation)
- Access this view using your JS framewok of choice (
jQuery.get()
for jQUery) - Using your JS framework, update some
<ul>
or<ol>
on your page by adding the content that you retrieved through your get call (And you could place it in some overlay that you’d display).
- [Answer]-Python Django Logging Issue
- [Answer]-Can Django user model inheritance and abstract class be used in combination?
- [Answer]-Include functions in class from another file in python