Handling multiple requests in a web application can be a challenging task, especially when the server needs to perform complex operations like making API requests and executing database queries. In this post, we will explore how Django can effectively manage simultaneous requests.
group_name_status = {'name': '', 'status':''}
def tokem_update(access_token):
try:
# Code for updating access token
except:
return False
def nema_status(request):
if request.method == 'POST':
try:
# Code for handling group status based on group ID
except:
messages.error(request, "Something went wrong. Try again.")
else:
messages.error(request, "Something went wrong. Try again.")
return redirect('nema:view_nema')
def get_group_name(request):
global group_name_status
return JsonResponse(group_name_status, status=200)
Request ajax and django URL simultaneously:
document.querySelectorAll('.nema-status-group').forEach(item => item.addEventListener('submit', e => {
for(let i = 0; i < 5000; i++){
setTimeout(get_table_name, i * 1000)
}
});
function get_table_name(){
// AJAX code to fetch and update group status
}