def success(request): if request.method == 'POST': f = Favorite(user=request.user.username, video=request.POST['video']) favorites = Favorite.objects.all() v = request.POST['video'] fs = Favorite.objects.filter(video=v) fu = Favorite.objects.filter(user=request.user.username) if fs and fu: return HttpResponse(v + " is already in your favorites.") f.save() return HttpResponse("Video: " + v + " was added to your favorites!")
def success(request): if request.method == 'POST': f = Favorite(user = request.user.username, video = request.POST['video']) favorites = Favorite.objects.all() v = request.POST['video'] fs = Favorite.objects.filter(video=v) fu = Favorite.objects.filter(user=request.user.username) if fs and fu: return HttpResponse(v + " is already in your favorites.") f.save() return HttpResponse("Video: "+ v + " was added to your favorites!")
def success(request): #How a user adds videos to their favorites. #If the video is already saved it won't add. if request.method == 'POST': f = Favorite(user = request.user.username, video = request.POST['video']) favorites = Favorite.objects.all() v = request.POST['video'] fs = Favorite.objects.filter(video=v, user=request.user.username) #fu = Favorite.objects.filter(user=request.user.username) if fs: return HttpResponseRedirect("/nodice/") f.save() return HttpResponseRedirect("/myfavs/")