def like_pet(req, pet_id): pet = Pet.objects.get(pk=pet_id) like = Like() like.pet = pet like.save() return redirect('list pets')
def like(request, pk): try: some_pet = Pet.objects.get(pk=pk) some_like = Like(pet=some_pet) some_like.save() except ObjectDoesNotExist: return redirect('pet_detail', pk) return redirect('pet_detail', pk)
def like_pet(request, pk): # already_liked = Likes.objects.first(user_id=user.id, pk=pk) # if already_liked : # return pet = Pet.objects.get(pk=pk) like = Like(test=str(pk)) like.pet = pet like.save() return redirect('pet details or comment', pk)
def like_pet(request, pk): liked = Like.objects.filter(user_id=request.user.userprofile.id, pet_id=pk) if liked: liked.delete() else: pet = Pet.objects.get(pk=pk) like = Like(test=str(pk), user=request.user.userprofile) like.pet = pet like.save() return redirect('pet details or comment', pk)
def pet_like(request, pk): like = Like.objects.filter(user_id=request.user.userprofile.id, pet_id=pk).first() if like: like.delete() else: pet = Pet.objects.get(pk=pk) like = Like(test=str(pk), user=request.user.userprofile) like.pet = pet like.save() return pet_details(request, pk)
def pets_likes(request, pk): like = Like.objects.filter(user_id=request.user.userprofile.id, pet_id=pk).first() if like: like.delete() else: pet_obj = Pet.objects.get(pk=pk) #zakachai kum user, a ne user profile like = Like(user=request.user.userprofile) like.pet = pet_obj like.save() return redirect('pets details', pk)
def like_pet(req, pk): #checks if liked and dislikes like = Like.objects.filter(user_id=req.user.userprofile.id, pet_id=pk).first() if like: like.delete() else: pet = Pet.objects.get(pk=pk) # new_like = pet.like_set.create() like = Like(pet=pet, user=req.user.userprofile) like.save() pet.like_set.add(like) pet.save() return redirect('pet_details', pk)
def like_pet(request, pk): pet = Pet.objects.get(pk=pk) like = Like(test=str(pk)) like.pet = pet like.save() return redirect(f'../details/{pet.id}')
def pet_like(request, pk): pet = Pet.objects.get(pk=pk) like = Like(test=str(pk)) like.pet = pet like.save() return pet_details(request, pk)
def like_pet(req, pk): pet = Pet.objects.get(pk=pk) like = Like(like_id=pk) like.pet = pet like.save() return redirect('list pet')
def like_pet(request, pk): pet = Pet.objects.get(pk=pk) like = Like(test=str(pk)) like.pet = pet like.save() return redirect('pet details or comment', pk)
def pets_like(request, pk): pet = Pet.objects.get(pk=pk) like = Like(test=str(pk)) like.pet = pet like.save() return redirect('pet-detail', pk)
def pet_like(request, pk): pet = Pet.objects.get(pk=pk) like = Like() like.pet = pet like.save() return redirect("pet detail or comment", pk)