Good day!

I decided to delve into the hitherto unexplored region: the python, the django and all that accompanying it.

The task was quite simple:

Cook a page with a text field in which you need to enter a test and immediately print this text somewhere, i.e. execute AJAX request.

Good. Made by It was not difficult, if not to take into account the initial acquaintance with new technologies. But I decided to go ahead and add the ability to save the entered data to the database.

It was also quite simple and did not take much time.

Pulling data from the database is also not difficult, as well as processing them in a template for the desired output.

But the problems started when I tried to fasten AJAX to this case, i.e. so that after entering the text box, changes are immediately displayed on the page.

In fact, this is also done, but it does not work as smoothly as it should.

It, as it is necessary, updates the data in accordance with the entered text, but does so extremely unstable, i.e. sometimes no update happens at all.

Judging by the terminal’s output, ajax_async_list is simply not called at some time. The reason for this behavior, alas, is not clear to me.

Below is a source repository.

https://gitlab.com/Aquinary/django-ajax

I will be glad to any help, thank you!

  • It is not entirely clear why not the text that was recorded in the database, but the one that was sent, is being loaded. In the file views.py 25 line. If the text is not recorded for example due to blocking or an error, do not know about it. - Igor
  • I understand what you mean. Sometimes ajax_async_list is called before ajax_async, i.e. and in ajax, as far as I know, the order in which requests are executed is not guaranteed. - Aquinary
  • With active work, there will also be problems with the code, if only the addition goes, then it is better to use the key - the value. We look not last added, but a unique key in a database. You can also just update one single record divided by markers or json format. - Igor

0