Answer the question
In order to leave comments, you need to log in
How to get django model data via ajax?
How to get data from the model (DB) on the client?
A person presses on a picture, its viewing opens, as well as a description.
The description is a formatted text that is stored in the RichTextField field of the model. It is clear that such data will not be stored in the title attribute of the tag, and therefore they should be obtained as needed.
I don't use jQuery or otherwise. For ajax request I write in JS, for example
fetch('http://127.0.0.1:8000/main/katalog/5/', {
method: 'GET',
headers: {'X-Requested-With': 'XMLHttpRequest'}});
fetch('/getinfo', {
method: 'GET',
headers: {'X-Requested-With': 'XMLHttpRequest'}});
Answer the question
In order to leave comments, you need to log in
write
https://docs.djangoproject.com/en/1.10/topics/http...
link
to url get
it If you don't understand what I wrote - go through the tutorial again
Create a url, bind to the view. It checks if request.is_ajax and sends json data. In js, you accept and output where you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question