I have a code of adding products list. when the user clicked the button a function is called which send the products list to the views by using ajax
function submition(container){
$.ajax({
url :'/compare_in/',
type : "POST",
data : {
com_list : container,
csrfmiddlewaretoken: '{{ csrf_token }}'
},
success : function() {
console.log('success')
},
error : function() {
console.log('Failure');
}
});
}
urls:
urlpatterns = [path('compare_in/', views.compare_in)]
now in the views code, the product's list value is manipulating and scraping the data by the list value and storing the data in the dictionary
def compare_in(request):
if request.method == 'POST':
compare_res = request.POST.getlist('com_list[]')
for item in range(len(compare_res)):
if re.compile('edmi').search(compare_res[item]):
compare_res[item] = 'xiaomi ' + compare_res[item]
phone_list = ','.join(e.lower() for e in compare_res)
phone_list = '-'.join(phone_list.split())
.
.
.
return HTTPResponse()
now I want to redirect to the different page with the value of the dictionary.
Note-return render() is not working