Q: django sessions to prevent user from multiple voting views.py
def like(request,option="food",restaurant = 1):
    if request.is_ajax:
        rest = 'rest'
        like = '%s-like' % str(option)

        if restaurant in request.session:

            if like not in request.session[restaurant]:
                request.session[restaurant][like] = str(like)
            else:
                return HttpResponse('warning')
        if restaurant not in request.session:
            request.session[restaurant] = restaurant


        r = Restaurant.objects.get(pk=restaurant)
        if option == "food":
            r.food_likes +=1
            r.save()
            return HttpResponse(str(r.food_likes))
        elif option=="service":
            r.service_likes +=1
            r.save()
            return HttpResponse(str(r.service_likes))
        elif option == "ambience":
            r.ambience_likes +=1
            r.save()
            return HttpResponse(str(r.ambience_likes))
    else:
        return redirect(request.META.get('HTTP_REFERER'))

error
'unicode' object does not support item assignment

line
request.session[restaurant][like] = str(like)

doubt
i am getting problem while setting the session key using a variable string , 
how am i supposed to set the session key 'like' inside 'restaurant' key??, please help 

A: First create an empty dictionary
request.session[restaurant] = dict()
Then do the assignment
request.session[restaurant][like] = str(like)
