1👍
✅
Based on your answer:
- You’re setting the value of picked_id from the request.POST dict in your view.
- All values in request.POST are, by default, strings.
- The object_list is probably a list from the ORM.
- Which means the element.id is a PK field.
- Which is gonna be an int.
So you need to cast ‘picked_id’ into an int before you save it to the session.
So:
request.session['picked_id'] = int(request.POST.get('object', 0))
… or however you’re doing it in your view.
Source:stackexchange.com