I have a Django app that is part of an online store. In the application, POST is processed in templatetag called posthandler.py, like this
{% load posthandler %}
{% posthandler %}
In index.html, which is always loading. After that, the file has a main bit like this
{% block primary %}{% endblock %}
Now this primary bit displays a value, a margin that could be adjusted into a posthandler bit. Value, value may be out of date. This leads to the fact that a person clicks on an item, adding it to his list of orders, but a page that needs two updates, before the stock value, correctly reflects the value in the database.
I think this is due to the processing order of templatetags, something like this:
- User clicks button to add to order list
- The page reloads through the view, first displaying the stock value in index.html based on what is currently in the database
- Posthandler.py works by subtracting it from the stock, so the database is now updated.
- The page with the wrong number is displayed, since this value was extracted from the database before it was configured.
I would have thought of processing the message in the view, but I want the same post-sender to work on all different pages, so this doesn't seem to be the way to go. Is there a better way to do this? Or can I make the main block execute only after templatetags?
source
share