def ajax_fav(request): user = request.user.get_profile() channel = Channel.objects.get(hash=request.POST["hash"]) fav = Favourite() fav.user = user fav.channel = channel fav.name = request.POST["name"] fav.slug = slugify(fav.name) fav.save() return HttpResponse("OK")
def save_fav(request): try: fav = Favourite.objects.get(id=request.POST["fav_id"]) except: fav = Favourite() user = request.user.get_profile() channel = Channels.objects.get(hash=request.POST["hash"]) fav.user = user fav.channel = channel fav.name = name fav.save() return HttpResponse("YAY")